System login : Changes allowing usage of (1) short name, (2) full name, (3) user number.
This commit is contained in:
parent
12053b4531
commit
2fcdfabd3c
@ -332,5 +332,14 @@ namespace Config.Entities
|
||||
#endif
|
||||
Count
|
||||
}
|
||||
|
||||
|
||||
public enum LoginMethod
|
||||
{
|
||||
UserName, /// = alias, abbreviation
|
||||
FullName, /// = description
|
||||
Number,
|
||||
Count
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ namespace Config.Entities
|
||||
///
|
||||
/// Default values
|
||||
///
|
||||
CreationUser = (Config.Data.CurrentUser != null) ? Config.Data.CurrentUser.Name : null;
|
||||
CreationUser = (Config.Data.CurrentUser != null) ? Config.Data.CurrentUser.UserName : null;
|
||||
CreationTime = DateTime.Now;
|
||||
LastChgUser = CreationUser;
|
||||
LastChgTime = CreationTime;
|
||||
|
||||
@ -16,11 +16,10 @@ namespace Config.Entities
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(User));
|
||||
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string UserName { get; set; } /// = name, alias, abbreviation
|
||||
public virtual string FullName { get; set; } /// = description
|
||||
public virtual int Number { get; set; }
|
||||
public virtual string Alias { get; set; }
|
||||
public virtual string Password { get; set; }
|
||||
public virtual string Description { get; set; }
|
||||
public virtual DateTime LastPwChange { get; set; }
|
||||
public virtual IList<Group> Groups { get; set; } //User can be a member of a list of groups
|
||||
|
||||
@ -37,13 +36,13 @@ namespace Config.Entities
|
||||
#endif
|
||||
}
|
||||
|
||||
public User(string name, int number, bool powerUser)
|
||||
public User(string userName, int number, bool powerUser)
|
||||
{
|
||||
Name = name;
|
||||
UserName = userName;
|
||||
Number = number;
|
||||
this.powerUser = powerUser;
|
||||
Groups = new List<Group>();
|
||||
Description = powerUser ? "Power user" : string.Empty;
|
||||
FullName = powerUser ? "Power user" : string.Empty;
|
||||
}
|
||||
|
||||
public virtual void AddGroup(Group group)
|
||||
@ -109,43 +108,6 @@ namespace Config.Entities
|
||||
return (Password == EncryptedPassword(password));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The FIRST of TWO possible user authorization method to be used
|
||||
/// when a specific group membership is required (you can use Grp.GID.None).
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="requiredGrupMembership"></param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool Authorize(string userName, string password, Grp.GID requiredGroupMembership)
|
||||
{
|
||||
if (Entities.User.IsPowerUser(userName, password))
|
||||
{
|
||||
Data.CurrentUser = this;
|
||||
Data.LastAuthorization = DateTime.Now;
|
||||
log.FatalFormat("Power user '{0}' authorized @level '{1}'", userName, requiredGroupMembership);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Name.ToLower() == userName.ToLower())
|
||||
{
|
||||
if (IsMemberOf(requiredGroupMembership) && CheckPassword(password))
|
||||
{
|
||||
Data.CurrentUser = this;
|
||||
Data.LastAuthorization = DateTime.Now;
|
||||
log.FatalFormat("User '{0}' authorized @level '{1}'", userName, requiredGroupMembership);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The FIRST of TWO possible user authorization method to be used
|
||||
@ -154,8 +116,55 @@ namespace Config.Entities
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="userName">User name</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <param name="requiredGrupMembership"></param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool Authorize(string userName, string password, Grp.GID requiredGroupMembership)
|
||||
{
|
||||
if (Entities.User.IsPowerUser(userName, password))
|
||||
{
|
||||
Data.CurrentUser = this;
|
||||
Data.LastAuthorization = DateTime.Now;
|
||||
log.FatalFormat("Power user '{0}' authorized @level '{1}'", userName, requiredGroupMembership);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (UserName.ToLower() == userName.ToLower())
|
||||
{
|
||||
if (IsMemberOf(requiredGroupMembership) && CheckPassword(password))
|
||||
{
|
||||
Data.CurrentUser = this;
|
||||
Data.LastAuthorization = DateTime.Now;
|
||||
log.FatalFormat("User '{0}' authorized @level '{1}'", userName, requiredGroupMembership);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// </summary>
|
||||
public virtual bool Authorize(string userName, string password)
|
||||
{
|
||||
return Authorize(userName, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The FIRST of TWO possible user authorization method to be used
|
||||
/// when a specific group membership is required (you can use Grp.GID.None).
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="number">User ID number</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <param name="requiredGrupMembership"></param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool AuthorizeNumber(int number, string password, Grp.GID requiredGroupMembership)
|
||||
@ -177,6 +186,15 @@ namespace Config.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// </summary>
|
||||
public virtual bool AuthorizeNumber(int number, string password)
|
||||
{
|
||||
return AuthorizeNumber(number, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The FIRST of TWO possible user authorization method to be used
|
||||
/// when a specific group membership is required (you can use Grp.GID.None).
|
||||
@ -184,19 +202,19 @@ namespace Config.Entities
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="alias"></param>
|
||||
/// <param name="fullName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="requiredGrupMembership"></param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool AuthorizeAlias(string alias, string password, Grp.GID requiredGroupMembership)
|
||||
public virtual bool AuthorizeFullName(string fullName, string password, Grp.GID requiredGroupMembership)
|
||||
{
|
||||
if (Alias.ToLower() == alias.ToLower())
|
||||
if (FullName.ToLower() == fullName.ToLower())
|
||||
{
|
||||
if (IsMemberOf(requiredGroupMembership) && CheckPassword(password))
|
||||
{
|
||||
Data.CurrentUser = this;
|
||||
Data.LastAuthorization = DateTime.Now;
|
||||
log.FatalFormat("User alias={0} authorized @level '{1}'", alias, requiredGroupMembership);
|
||||
log.FatalFormat("User alias={0} authorized @level '{1}'", fullName, requiredGroupMembership);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -207,49 +225,13 @@ namespace Config.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="userName">User name</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool Authorize(string userName, string password)
|
||||
{
|
||||
return Authorize(userName, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="number">User ID number</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool AuthorizeNumber(int number, string password)
|
||||
public virtual bool AuthorizeFullName(string fullName, string password)
|
||||
{
|
||||
return AuthorizeNumber(number, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="userName">Alias (abbreviated user name)</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool AuthorizeAlias(string alias, string password)
|
||||
{
|
||||
return AuthorizeAlias(alias, password, Grp.GID.None);
|
||||
return AuthorizeFullName(fullName, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -260,23 +242,24 @@ namespace Config.Entities
|
||||
public static User AuthorizeDummyUser(string username)
|
||||
{
|
||||
User user = new User();
|
||||
user.Name = username;
|
||||
user.UserName = username;
|
||||
Data.CurrentUser = user;
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from an ARBITRARY database.
|
||||
/// </summary>
|
||||
/// <param name="username">User name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByName(string username, DBSettings dbSettings)
|
||||
public static User LoadUserByName(string userName, DBSettings dbSettings)
|
||||
{
|
||||
IList<User> listOfUsers = FluentCommon.CreateSessionFactory(DBKind.Config, dbSettings, false)
|
||||
.OpenSession()
|
||||
.QueryOver<User>()
|
||||
.Where(x => (x.Name.ToLower() == username.ToLower()))
|
||||
.List();
|
||||
.CreateQuery("FROM User WHERE LOWER(UserName) = :username") /// Note: QueryOver<User>().Where(x => x.UserName.ToLower() == ... does not work
|
||||
.SetParameter("username", userName.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
@ -286,16 +269,81 @@ namespace Config.Entities
|
||||
/// </summary>
|
||||
/// <param name="username">User name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByName(string username)
|
||||
public static User LoadUserByName(string userName)
|
||||
{
|
||||
IList<User> listOfUsers = FluentCommon.CreateSession(DBKind.Config)
|
||||
.CreateQuery("FROM User WHERE LOWER(UserName) = :username") /// Note: QueryOver<User>().Where(x => x.UserName.ToLower() == ... does not work
|
||||
.SetParameter("username", userName.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given full name from an ARBITRARY database.
|
||||
/// </summary>
|
||||
/// <param name="fullName">Full name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByFullName(string fullName, Config.DBSettings dbSettings)
|
||||
{
|
||||
IList<User> listOfUsers = FluentCommon.CreateSessionFactory(DBKind.Config, dbSettings, false)
|
||||
.OpenSession()
|
||||
.CreateQuery("FROM User WHERE LOWER(Description) = :fullname") /// Note: QueryOver<User>().Where(x => x.FullName.ToLower() == ... does not work
|
||||
.SetParameter("fullname", fullName.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given full name from the users database.
|
||||
/// </summary>
|
||||
/// <param name="fullName">Full name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByFullName(string fullName)
|
||||
{
|
||||
IList<User> listOfUsers = FluentCommon.CreateSession(DBKind.Config)
|
||||
.CreateQuery("FROM User WHERE LOWER(Description) = :fullname") /// Note: QueryOver<User>().Where(x => x.FullName.ToLower() == ... does not work
|
||||
.SetParameter("fullname", fullName.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from an ARBITRARY database.
|
||||
/// </summary>
|
||||
/// <param name="number">User ID number for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByNumber(int number, Config.DBSettings dbSettings)
|
||||
{
|
||||
IList<User> listOfUsers = FluentCommon.CreateSessionFactory(DBKind.Config, dbSettings, false)
|
||||
.OpenSession()
|
||||
.QueryOver<User>()
|
||||
.Where(x => (x.Name.ToLower() == username.ToLower()))
|
||||
.Where(x => (x.Number == number))
|
||||
.List();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from the users database.
|
||||
/// </summary>
|
||||
/// <param name="number">User ID number for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByNumber(int number)
|
||||
{
|
||||
IList<User> listOfUsers = FluentCommon.CreateSession(DBKind.Config)
|
||||
.QueryOver<User>()
|
||||
.Where(x => (x.Number == number))
|
||||
.List();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// returns an IList of all Users
|
||||
/// </summary>
|
||||
|
||||
@ -41,7 +41,7 @@ namespace Config.Entities
|
||||
WMType procedure = new WMType()
|
||||
{
|
||||
CreateTime = DateTime.Now,
|
||||
CreateUserName = Config.Data.CurrentUser.Name,
|
||||
CreateUserName = Config.Data.CurrentUser.UserName,
|
||||
CreateDescription = "A default water meter created.",
|
||||
Name = "Watermeter",
|
||||
PulseRate = 1000,
|
||||
|
||||
@ -182,8 +182,8 @@ namespace Config
|
||||
/// Create the user 'admin' add his groups
|
||||
var admin = new Entities.User
|
||||
{
|
||||
Name = Data.AdminUsername,
|
||||
Description = Strings.Administrator,
|
||||
UserName = Data.AdminUsername,
|
||||
FullName = Strings.Administrator,
|
||||
LastPwChange = DateTime.Now
|
||||
};
|
||||
admin.SetPassword(Data.AdminPassword);
|
||||
|
||||
@ -4,23 +4,23 @@ namespace Config
|
||||
{
|
||||
public interface IUser
|
||||
{
|
||||
string Name { get; }
|
||||
string Alias { get; }
|
||||
string UserName { get; }
|
||||
string FullName { get; }
|
||||
int Number { get; }
|
||||
|
||||
bool IsMemberOf(Grp.GID group);
|
||||
|
||||
bool Authorize(string username, string password);
|
||||
bool Authorize(string username, string password, Grp.GID requiredGroup);
|
||||
bool Authorize(string userName, string password);
|
||||
bool Authorize(string userName, string password, Grp.GID requiredGroup);
|
||||
|
||||
bool AuthorizeAlias(string alias, string password);
|
||||
bool AuthorizeAlias(string alias, string password, Grp.GID requiredGroup);
|
||||
bool AuthorizeFullName(string fullName, string password);
|
||||
bool AuthorizeFullName(string fullName, string password, Grp.GID requiredGroup);
|
||||
|
||||
bool AuthorizeNumber(int number, string password);
|
||||
bool AuthorizeNumber(int number, string password, Grp.GID requiredGroup);
|
||||
|
||||
//IUser LoadUserByName(string username, DBSettings dbSettings);
|
||||
//IUser LoadUserByFullName(string alias, DBSettings dbSettings);
|
||||
//IUser LoadUserByNumber(int number, DBSettings dbSettings);
|
||||
//IUser LoadUserByAlias(string alias, DBSettings dbSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,10 +10,10 @@ namespace Config.Mappings
|
||||
public UserMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.UserName).Column("Name");
|
||||
Map(x => x.Number);
|
||||
Map(x => x.Password);
|
||||
Map(x => x.Description);
|
||||
Map(x => x.FullName).Column("Description");
|
||||
Map(x => x.LastPwChange);
|
||||
HasMany(x => x.Groups)
|
||||
.Cascade.All();
|
||||
|
||||
@ -177,7 +177,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
//batch.EndTime.ToShortDateString() + " " + batch.EndTime.ToShortTimeString(),
|
||||
string.Format("{0:yyyy.MM.dd HH:mm}", batch.EndTime),
|
||||
batch.ProcedureName,
|
||||
Config.Data.CurrentUser.Name,
|
||||
Config.Data.CurrentUser.UserName,
|
||||
batch.AmbientTempAve().ToString("F1") + " °C",
|
||||
Config.Units.ConvertTo(Config.Unit.mbar, batch.AmbientPressAve()).ToString("F0") + " mbar",
|
||||
batch.AmbientHumiAve().ToString("F0") + " %",
|
||||
|
||||
@ -319,7 +319,7 @@ namespace TBF.BenchControl.Sequences
|
||||
///
|
||||
BatchRslts = Results.BatchResults.NewFromProcedure(Program.LocalSettings.BatchNr,
|
||||
(BenchInfo != null) ? BenchInfo.TestBenchId : 1,
|
||||
Config.Data.CurrentUser.Name, Config.Data.CurrentUser.Number, Program.Version,
|
||||
Config.Data.CurrentUser.UserName, Config.Data.CurrentUser.Number, Program.Version,
|
||||
StateMachine.Procedure, waterMeterData, waterMeterParts);
|
||||
StateMachine.CycleStartTimeStamp = BatchRslts.Batch.StartTime;
|
||||
|
||||
|
||||
@ -27,8 +27,8 @@ namespace TBF.Forms
|
||||
{
|
||||
Localize();
|
||||
|
||||
txtName.Text = CurrentEditUser.Name;
|
||||
txtDescription.Text = CurrentEditUser.Description;
|
||||
txtName.Text = CurrentEditUser.UserName;
|
||||
txtDescription.Text = CurrentEditUser.FullName;
|
||||
txtPassword.Text = "";
|
||||
ShowGroups();
|
||||
}
|
||||
@ -79,13 +79,13 @@ namespace TBF.Forms
|
||||
}
|
||||
|
||||
|
||||
CurrentEditUser.Name = txtName.Text;
|
||||
CurrentEditUser.UserName = txtName.Text;
|
||||
|
||||
if (txtPassword.Text != "")
|
||||
{
|
||||
CurrentEditUser.SetPassword(txtPassword.Text);
|
||||
}
|
||||
CurrentEditUser.Description = txtDescription.Text;
|
||||
CurrentEditUser.FullName = txtDescription.Text;
|
||||
|
||||
// Groups
|
||||
CurrentEditUser.Groups.Clear();
|
||||
@ -115,7 +115,7 @@ namespace TBF.Forms
|
||||
{
|
||||
if (person.Id != CurrentEditUser.Id) {
|
||||
// other user
|
||||
if (person.Name.ToLower() == Username.ToLower())
|
||||
if (person.UserName.ToLower() == Username.ToLower())
|
||||
{
|
||||
// Name is equal, so allready taken
|
||||
return true;
|
||||
|
||||
@ -59,7 +59,7 @@ namespace TBF.Forms
|
||||
listViewUsers.Items.Clear();
|
||||
foreach (var person in ListOfUsers)
|
||||
{
|
||||
ListViewItem item = new ListViewItem(person.Name);
|
||||
ListViewItem item = new ListViewItem(person.UserName);
|
||||
item.SubItems.Add(person.Id.ToString());
|
||||
item.Tag = person;
|
||||
this.listViewUsers.Items.Add(item);
|
||||
|
||||
133
TestBenchFramework/Forms/LoginDlg.Designer.cs
generated
133
TestBenchFramework/Forms/LoginDlg.Designer.cs
generated
@ -31,77 +31,78 @@ namespace TBF.Forms
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlg));
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.passwordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.userNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
resources.ApplyResources(this.label1, "label1");
|
||||
this.label1.Name = "label1";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
resources.ApplyResources(this.label2, "label2");
|
||||
this.label2.Name = "label2";
|
||||
//
|
||||
// passwordTextBox
|
||||
//
|
||||
resources.ApplyResources(this.passwordTextBox, "passwordTextBox");
|
||||
this.passwordTextBox.Name = "passwordTextBox";
|
||||
this.passwordTextBox.UseSystemPasswordChar = true;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// userNameTextBox
|
||||
//
|
||||
resources.ApplyResources(this.userNameTextBox, "userNameTextBox");
|
||||
this.userNameTextBox.Name = "userNameTextBox";
|
||||
//
|
||||
// LoginDlg
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.Controls.Add(this.userNameTextBox);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.passwordTextBox);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Name = "LoginDlg";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Load += new System.EventHandler(this.LoginDlg_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlg));
|
||||
this.aliasLabel = new System.Windows.Forms.Label();
|
||||
this.passwordLabel = new System.Windows.Forms.Label();
|
||||
this.passwordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.userNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// aliasLabel
|
||||
//
|
||||
resources.ApplyResources(this.aliasLabel, "aliasLabel");
|
||||
this.aliasLabel.Name = "aliasLabel";
|
||||
this.aliasLabel.Click += new System.EventHandler(this.aliasLabel_Click);
|
||||
//
|
||||
// passwordLabel
|
||||
//
|
||||
resources.ApplyResources(this.passwordLabel, "passwordLabel");
|
||||
this.passwordLabel.Name = "passwordLabel";
|
||||
//
|
||||
// passwordTextBox
|
||||
//
|
||||
resources.ApplyResources(this.passwordTextBox, "passwordTextBox");
|
||||
this.passwordTextBox.Name = "passwordTextBox";
|
||||
this.passwordTextBox.UseSystemPasswordChar = true;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// userNameTextBox
|
||||
//
|
||||
resources.ApplyResources(this.userNameTextBox, "userNameTextBox");
|
||||
this.userNameTextBox.Name = "userNameTextBox";
|
||||
//
|
||||
// LoginDlg
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.Controls.Add(this.userNameTextBox);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.passwordTextBox);
|
||||
this.Controls.Add(this.passwordLabel);
|
||||
this.Controls.Add(this.aliasLabel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Name = "LoginDlg";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Load += new System.EventHandler(this.LoginDlg_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label aliasLabel;
|
||||
private System.Windows.Forms.Label passwordLabel;
|
||||
private System.Windows.Forms.TextBox userNameTextBox;
|
||||
private System.Windows.Forms.TextBox passwordTextBox;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
|
||||
@ -24,6 +24,9 @@ namespace TBF.Forms
|
||||
Config.Grp.GID requiredGroupMembership = Config.Grp.GID.Invalid;
|
||||
bool noDatabase;
|
||||
|
||||
Config.Entities.LoginMethod method;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
@ -73,16 +76,34 @@ namespace TBF.Forms
|
||||
|
||||
private void LoginDlg_Load(object sender, EventArgs e)
|
||||
{
|
||||
Text = Strings.User_Login + " TBF v." + Program.Version;
|
||||
label1.Text = Strings.Username;
|
||||
label2.Text = Strings.Password;
|
||||
okButton.Text = Strings.OkBtnText;
|
||||
cancelButton.Text = Strings.CancelBtnText;
|
||||
|
||||
if (user == null) userNameTextBox.Select();
|
||||
else passwordTextBox.Select();
|
||||
Localize();
|
||||
|
||||
if (user == null)
|
||||
userNameTextBox.Select();
|
||||
else
|
||||
passwordTextBox.Select();
|
||||
}
|
||||
|
||||
void Localize()
|
||||
{
|
||||
Text = Strings.User_Login + " TBF v." + Program.Version;
|
||||
aliasLabel.Text = GetAliasLabel();
|
||||
passwordLabel.Text = Strings.Password;
|
||||
okButton.Text = Strings.OkBtnText;
|
||||
cancelButton.Text = Strings.CancelBtnText;
|
||||
}
|
||||
|
||||
string GetAliasLabel()
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
default:
|
||||
case Config.Entities.LoginMethod.UserName: return Strings.User_name;
|
||||
case Config.Entities.LoginMethod.FullName: return Strings.Full_name;
|
||||
case Config.Entities.LoginMethod.Number: return Strings.User_code;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to authorize the user when OK clicked.
|
||||
/// </summary>
|
||||
@ -98,13 +119,20 @@ namespace TBF.Forms
|
||||
Config.Entities.User loadedUser = Config.Entities.User.LoadUserByName(user);
|
||||
if (loadedUser != null)
|
||||
{
|
||||
if (requiredGroupMembership == Config.Grp.GID.Invalid)
|
||||
switch (method)
|
||||
{
|
||||
authorized = loadedUser.Authorize(user, password);
|
||||
}
|
||||
else
|
||||
{
|
||||
authorized = loadedUser.Authorize(user, password, requiredGroupMembership);
|
||||
default:
|
||||
case Config.Entities.LoginMethod.UserName:
|
||||
authorized = (requiredGroupMembership == Config.Grp.GID.Invalid) ? loadedUser.Authorize(user, password) : loadedUser.Authorize(user, password, requiredGroupMembership);
|
||||
break;
|
||||
case Config.Entities.LoginMethod.FullName:
|
||||
authorized = (requiredGroupMembership == Config.Grp.GID.Invalid) ? loadedUser.AuthorizeFullName(user, password) : loadedUser.AuthorizeFullName(user, password, requiredGroupMembership);
|
||||
break;
|
||||
case Config.Entities.LoginMethod.Number:
|
||||
int number;
|
||||
if (!int.TryParse(user, out number)) break;
|
||||
authorized = (requiredGroupMembership == Config.Grp.GID.Invalid) ? loadedUser.AuthorizeNumber(number, password) : loadedUser.AuthorizeNumber(number, password, requiredGroupMembership);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,5 +164,13 @@ namespace TBF.Forms
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
private void aliasLabel_Click(object sender, EventArgs e)
|
||||
{
|
||||
method++;
|
||||
if (method == Config.Entities.LoginMethod.Count)
|
||||
method = 0;
|
||||
aliasLabel.Text = GetAliasLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,59 +118,59 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
|
||||
<data name="aliasLabel.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>8, 24</value>
|
||||
<data name="aliasLabel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>11, 24</value>
|
||||
</data>
|
||||
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<data name="aliasLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>58, 13</value>
|
||||
</data>
|
||||
<data name="label1.TabIndex" type="System.Int32, mscorlib">
|
||||
<data name="aliasLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="label1.Text" xml:space="preserve">
|
||||
<data name="aliasLabel.Text" xml:space="preserve">
|
||||
<value>User name</value>
|
||||
</data>
|
||||
<data name=">>label1.Name" xml:space="preserve">
|
||||
<value>label1</value>
|
||||
<data name=">>aliasLabel.Name" xml:space="preserve">
|
||||
<value>aliasLabel</value>
|
||||
</data>
|
||||
<data name=">>label1.Type" xml:space="preserve">
|
||||
<data name=">>aliasLabel.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label1.Parent" xml:space="preserve">
|
||||
<data name=">>aliasLabel.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label1.ZOrder" xml:space="preserve">
|
||||
<data name=">>aliasLabel.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
|
||||
<data name="passwordLabel.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>8, 51</value>
|
||||
<data name="passwordLabel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>11, 51</value>
|
||||
</data>
|
||||
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<data name="passwordLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>53, 13</value>
|
||||
</data>
|
||||
<data name="label2.TabIndex" type="System.Int32, mscorlib">
|
||||
<data name="passwordLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="label2.Text" xml:space="preserve">
|
||||
<data name="passwordLabel.Text" xml:space="preserve">
|
||||
<value>Password</value>
|
||||
</data>
|
||||
<data name=">>label2.Name" xml:space="preserve">
|
||||
<value>label2</value>
|
||||
<data name=">>passwordLabel.Name" xml:space="preserve">
|
||||
<value>passwordLabel</value>
|
||||
</data>
|
||||
<data name=">>label2.Type" xml:space="preserve">
|
||||
<data name=">>passwordLabel.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label2.Parent" xml:space="preserve">
|
||||
<data name=">>passwordLabel.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label2.ZOrder" xml:space="preserve">
|
||||
<data name=">>passwordLabel.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
@ -202,7 +202,7 @@
|
||||
<value>Top, Right</value>
|
||||
</data>
|
||||
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>317, 48</value>
|
||||
<value>314, 48</value>
|
||||
</data>
|
||||
<data name="cancelButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 28</value>
|
||||
@ -229,7 +229,7 @@
|
||||
<value>Top, Right</value>
|
||||
</data>
|
||||
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>317, 14</value>
|
||||
<value>314, 14</value>
|
||||
</data>
|
||||
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 28</value>
|
||||
|
||||
@ -21,14 +21,15 @@ namespace TBF.Forms
|
||||
public partial class LoginDlgWithBenchSelection : Form
|
||||
{
|
||||
// Private fields
|
||||
string user;
|
||||
string alias;
|
||||
string password;
|
||||
string benchName = null;
|
||||
|
||||
// Readonly public properties to do the authorization.
|
||||
public string User { get { return user; } }
|
||||
public string Alias { get { return alias; } }
|
||||
public string Password { get { return password; } }
|
||||
public string BenchName { get { return benchName; } }
|
||||
public Config.Entities.LoginMethod Method;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
@ -67,13 +68,24 @@ namespace TBF.Forms
|
||||
void Localize()
|
||||
{
|
||||
Text = Strings.User_Login + " TBF v." + Program.Version;
|
||||
label1.Text = Strings.Username;
|
||||
label2.Text = Strings.Password;
|
||||
label3.Text = Strings.Test_bench;
|
||||
aliasLabel.Text = GetAliasLabel();
|
||||
passwordLabel.Text = Strings.Password;
|
||||
testBenchLabel.Text = Strings.Test_bench;
|
||||
okButton.Text = Strings.OkBtnText;
|
||||
cancelButton.Text = Strings.CancelBtnText;
|
||||
}
|
||||
|
||||
string GetAliasLabel()
|
||||
{
|
||||
switch (Method)
|
||||
{
|
||||
default:
|
||||
case Config.Entities.LoginMethod.UserName: return Strings.User_name;
|
||||
case Config.Entities.LoginMethod.FullName: return Strings.Full_name;
|
||||
case Config.Entities.LoginMethod.Number: return Strings.User_code;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OK clicked (authorization is done outside this dialog).
|
||||
/// </summary>
|
||||
@ -81,7 +93,7 @@ namespace TBF.Forms
|
||||
{
|
||||
if (testBenchComboBox.SelectedItem != null)
|
||||
{
|
||||
user = userNameTextBox.Text;
|
||||
alias = userNameTextBox.Text;
|
||||
password = passwordTextBox.Text;
|
||||
benchName = testBenchComboBox.SelectedItem.ToString();
|
||||
|
||||
@ -120,5 +132,13 @@ namespace TBF.Forms
|
||||
passwordTextBox.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void aliasLabel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Method++;
|
||||
if (Method == Config.Entities.LoginMethod.Count)
|
||||
Method = 0;
|
||||
aliasLabel.Text = GetAliasLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,99 +31,100 @@ namespace TBF.Forms
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlgWithBenchSelection));
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.testBenchComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.passwordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.userNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
resources.ApplyResources(this.label1, "label1");
|
||||
this.label1.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.label1.Name = "label1";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
resources.ApplyResources(this.label2, "label2");
|
||||
this.label2.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.label2.Name = "label2";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
resources.ApplyResources(this.label3, "label3");
|
||||
this.label3.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.label3.Name = "label3";
|
||||
//
|
||||
// testBenchComboBox
|
||||
//
|
||||
resources.ApplyResources(this.testBenchComboBox, "testBenchComboBox");
|
||||
this.testBenchComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.testBenchComboBox.FormattingEnabled = true;
|
||||
this.testBenchComboBox.Name = "testBenchComboBox";
|
||||
//
|
||||
// passwordTextBox
|
||||
//
|
||||
resources.ApplyResources(this.passwordTextBox, "passwordTextBox");
|
||||
this.passwordTextBox.Name = "passwordTextBox";
|
||||
this.passwordTextBox.UseSystemPasswordChar = true;
|
||||
this.passwordTextBox.TextChanged += new System.EventHandler(this.passwordTextBox_TextChanged);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// userNameTextBox
|
||||
//
|
||||
resources.ApplyResources(this.userNameTextBox, "userNameTextBox");
|
||||
this.userNameTextBox.Name = "userNameTextBox";
|
||||
this.userNameTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox_KeyPress);
|
||||
//
|
||||
// LoginDlgWithBenchSelection
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.userNameTextBox);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.passwordTextBox);
|
||||
this.Controls.Add(this.testBenchComboBox);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Name = "LoginDlgWithBenchSelection";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Load += new System.EventHandler(this.LoginDlgWithBenchSelection_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlgWithBenchSelection));
|
||||
this.aliasLabel = new System.Windows.Forms.Label();
|
||||
this.passwordLabel = new System.Windows.Forms.Label();
|
||||
this.testBenchLabel = new System.Windows.Forms.Label();
|
||||
this.testBenchComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.passwordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.userNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// aliasLabel
|
||||
//
|
||||
resources.ApplyResources(this.aliasLabel, "aliasLabel");
|
||||
this.aliasLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.aliasLabel.Name = "aliasLabel";
|
||||
this.aliasLabel.Click += new System.EventHandler(this.aliasLabel_Click);
|
||||
//
|
||||
// passwordLabel
|
||||
//
|
||||
resources.ApplyResources(this.passwordLabel, "passwordLabel");
|
||||
this.passwordLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.passwordLabel.Name = "passwordLabel";
|
||||
//
|
||||
// testBenchLabel
|
||||
//
|
||||
resources.ApplyResources(this.testBenchLabel, "testBenchLabel");
|
||||
this.testBenchLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.testBenchLabel.Name = "testBenchLabel";
|
||||
//
|
||||
// testBenchComboBox
|
||||
//
|
||||
resources.ApplyResources(this.testBenchComboBox, "testBenchComboBox");
|
||||
this.testBenchComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.testBenchComboBox.FormattingEnabled = true;
|
||||
this.testBenchComboBox.Name = "testBenchComboBox";
|
||||
//
|
||||
// passwordTextBox
|
||||
//
|
||||
resources.ApplyResources(this.passwordTextBox, "passwordTextBox");
|
||||
this.passwordTextBox.Name = "passwordTextBox";
|
||||
this.passwordTextBox.UseSystemPasswordChar = true;
|
||||
this.passwordTextBox.TextChanged += new System.EventHandler(this.passwordTextBox_TextChanged);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.ImageKey = global::TBF.Resources.Strings.Closing_the_tank;
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// userNameTextBox
|
||||
//
|
||||
resources.ApplyResources(this.userNameTextBox, "userNameTextBox");
|
||||
this.userNameTextBox.Name = "userNameTextBox";
|
||||
this.userNameTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox_KeyPress);
|
||||
//
|
||||
// LoginDlgWithBenchSelection
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.userNameTextBox);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.passwordTextBox);
|
||||
this.Controls.Add(this.testBenchComboBox);
|
||||
this.Controls.Add(this.testBenchLabel);
|
||||
this.Controls.Add(this.passwordLabel);
|
||||
this.Controls.Add(this.aliasLabel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Name = "LoginDlgWithBenchSelection";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Load += new System.EventHandler(this.LoginDlgWithBenchSelection_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label aliasLabel;
|
||||
private System.Windows.Forms.Label passwordLabel;
|
||||
private System.Windows.Forms.Label testBenchLabel;
|
||||
private System.Windows.Forms.TextBox userNameTextBox;
|
||||
private System.Windows.Forms.TextBox passwordTextBox;
|
||||
private System.Windows.Forms.ComboBox testBenchComboBox;
|
||||
|
||||
@ -118,86 +118,86 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
|
||||
<data name="aliasLabel.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>8, 17</value>
|
||||
<data name="aliasLabel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>11, 17</value>
|
||||
</data>
|
||||
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<data name="aliasLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>58, 13</value>
|
||||
</data>
|
||||
<data name="label1.TabIndex" type="System.Int32, mscorlib">
|
||||
<data name="aliasLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="label1.Text" xml:space="preserve">
|
||||
<data name="aliasLabel.Text" xml:space="preserve">
|
||||
<value>User name</value>
|
||||
</data>
|
||||
<data name=">>label1.Name" xml:space="preserve">
|
||||
<value>label1</value>
|
||||
<data name=">>aliasLabel.Name" xml:space="preserve">
|
||||
<value>aliasLabel</value>
|
||||
</data>
|
||||
<data name=">>label1.Type" xml:space="preserve">
|
||||
<data name=">>aliasLabel.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label1.Parent" xml:space="preserve">
|
||||
<data name=">>aliasLabel.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label1.ZOrder" xml:space="preserve">
|
||||
<data name=">>aliasLabel.ZOrder" xml:space="preserve">
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
|
||||
<data name="passwordLabel.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>8, 44</value>
|
||||
<data name="passwordLabel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>11, 44</value>
|
||||
</data>
|
||||
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<data name="passwordLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>53, 13</value>
|
||||
</data>
|
||||
<data name="label2.TabIndex" type="System.Int32, mscorlib">
|
||||
<data name="passwordLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="label2.Text" xml:space="preserve">
|
||||
<data name="passwordLabel.Text" xml:space="preserve">
|
||||
<value>Password</value>
|
||||
</data>
|
||||
<data name=">>label2.Name" xml:space="preserve">
|
||||
<value>label2</value>
|
||||
<data name=">>passwordLabel.Name" xml:space="preserve">
|
||||
<value>passwordLabel</value>
|
||||
</data>
|
||||
<data name=">>label2.Type" xml:space="preserve">
|
||||
<data name=">>passwordLabel.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label2.Parent" xml:space="preserve">
|
||||
<data name=">>passwordLabel.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label2.ZOrder" xml:space="preserve">
|
||||
<data name=">>passwordLabel.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
|
||||
<data name="testBenchLabel.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label3.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>8, 70</value>
|
||||
<data name="testBenchLabel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>11, 70</value>
|
||||
</data>
|
||||
<data name="label3.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<data name="testBenchLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>61, 13</value>
|
||||
</data>
|
||||
<data name="label3.TabIndex" type="System.Int32, mscorlib">
|
||||
<data name="testBenchLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="label3.Text" xml:space="preserve">
|
||||
<data name="testBenchLabel.Text" xml:space="preserve">
|
||||
<value>Test bench</value>
|
||||
</data>
|
||||
<data name=">>label3.Name" xml:space="preserve">
|
||||
<value>label3</value>
|
||||
<data name=">>testBenchLabel.Name" xml:space="preserve">
|
||||
<value>testBenchLabel</value>
|
||||
</data>
|
||||
<data name=">>label3.Type" xml:space="preserve">
|
||||
<data name=">>testBenchLabel.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label3.Parent" xml:space="preserve">
|
||||
<data name=">>testBenchLabel.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label3.ZOrder" xml:space="preserve">
|
||||
<data name=">>testBenchLabel.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
@ -253,7 +253,7 @@
|
||||
<value>Top, Right</value>
|
||||
</data>
|
||||
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>317, 48</value>
|
||||
<value>314, 48</value>
|
||||
</data>
|
||||
<data name="cancelButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 28</value>
|
||||
@ -280,7 +280,7 @@
|
||||
<value>Top, Right</value>
|
||||
</data>
|
||||
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>317, 14</value>
|
||||
<value>314, 14</value>
|
||||
</data>
|
||||
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 28</value>
|
||||
|
||||
@ -169,7 +169,7 @@ namespace TBF.Forms
|
||||
}
|
||||
else if (Program.LocalSettings.AlwaysAskPasswdWhenUnlocking)
|
||||
{
|
||||
if ((new LoginDlg(Config.Data.CurrentUser.Name, RequiredGroupMembership)).ShowDialog() != DialogResult.OK) return;
|
||||
if ((new LoginDlg(Config.Data.CurrentUser.UserName, RequiredGroupMembership)).ShowDialog() != DialogResult.OK) return;
|
||||
}
|
||||
|
||||
unlocked = true;
|
||||
|
||||
@ -98,7 +98,7 @@ namespace TBF
|
||||
usersTSMenuItem.Visible = Config.Data.CurrentUser.IsMemberOf(Config.Grp.GID.Administrators) ||
|
||||
Config.Data.CurrentUser.IsMemberOf(Config.Grp.GID.HeadOfLab);
|
||||
|
||||
upgradeTSMenuItem.Visible = Config.Data.CurrentUser.IsMemberOf(Config.Grp.GID.Administrators) && Config.Data.CurrentUser.Name == "milan";
|
||||
upgradeTSMenuItem.Visible = Config.Data.CurrentUser.IsMemberOf(Config.Grp.GID.Administrators) && Config.Data.CurrentUser.UserName == "milan";
|
||||
|
||||
benchInitializationFailed = false;
|
||||
///
|
||||
@ -335,7 +335,7 @@ namespace TBF
|
||||
|
||||
public void UpdateUser()
|
||||
{
|
||||
userInfoStatusLabel.Text = string.Format("{0}: {1} , ", Strings.User, Config.Data.CurrentUser.Name);
|
||||
userInfoStatusLabel.Text = string.Format("{0}: {1} , ", Strings.User, Config.Data.CurrentUser.UserName);
|
||||
}
|
||||
|
||||
public void UpdateStatusP(string statusPStr)
|
||||
|
||||
@ -208,10 +208,10 @@ namespace TBF
|
||||
{
|
||||
bool authorized = false;
|
||||
|
||||
if (User.IsPowerUser(loginDlgBench.User, loginDlgBench.Password))
|
||||
if (User.IsPowerUser(loginDlgBench.Alias, loginDlgBench.Password))
|
||||
{
|
||||
loadedUser = new User(loginDlgBench.User, 6, true);
|
||||
authorized = loadedUser.Authorize(loginDlgBench.User, loginDlgBench.Password);
|
||||
loadedUser = new User(loginDlgBench.Alias, 6, true);
|
||||
authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password);
|
||||
}
|
||||
|
||||
///
|
||||
@ -228,15 +228,27 @@ namespace TBF
|
||||
settingsChanged = true;
|
||||
}
|
||||
|
||||
/// Load user from the UsersAndGroupsDB database
|
||||
loadedUser = Users.Entities.User.LoadUserByName(loginDlgBench.User,
|
||||
LocalSettings.TestBenches[i].UsersDBSettings);
|
||||
if (loadedUser != null)
|
||||
/// Load and authorise user from the UsersDB database
|
||||
switch (loginDlgBench.Method)
|
||||
{
|
||||
authorized = loadedUser.Authorize(loginDlgBench.User, loginDlgBench.Password);
|
||||
|
||||
if (authorized && settingsChanged) LocalSettings.Save();
|
||||
default:
|
||||
case Config.Entities.LoginMethod.UserName:
|
||||
loadedUser = Users.Entities.User.LoadUserByName(loginDlgBench.Alias, LocalSettings.TestBenches[i].UsersDBSettings);
|
||||
if (loadedUser != null) authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password);
|
||||
break;
|
||||
case Config.Entities.LoginMethod.FullName:
|
||||
loadedUser = Users.Entities.User.LoadUserByFullName(loginDlgBench.Alias, LocalSettings.TestBenches[i].UsersDBSettings);
|
||||
if (loadedUser != null) authorized = loadedUser.AuthorizeFullName(loginDlgBench.Alias, loginDlgBench.Password);
|
||||
break;
|
||||
case Config.Entities.LoginMethod.Number:
|
||||
int number;
|
||||
if (!int.TryParse(loginDlgBench.Alias, out number)) break;
|
||||
loadedUser = Users.Entities.User.LoadUserByNumber(number, LocalSettings.TestBenches[i].UsersDBSettings);
|
||||
if (loadedUser != null) authorized = loadedUser.AuthorizeNumber(number, loginDlgBench.Password);
|
||||
break;
|
||||
}
|
||||
|
||||
if (settingsChanged && authorized) LocalSettings.Save();
|
||||
}
|
||||
|
||||
///
|
||||
@ -244,14 +256,26 @@ namespace TBF
|
||||
///
|
||||
if (!authorized)
|
||||
{
|
||||
/// Load user from the UsersAndGroupsDB database
|
||||
loadedUser = User.LoadUserByName(loginDlgBench.User,
|
||||
LocalSettings.TestBenches[i].ProceduresDBSettings);
|
||||
if (loadedUser != null)
|
||||
{
|
||||
authorized = loadedUser.Authorize(loginDlgBench.User, loginDlgBench.Password);
|
||||
}
|
||||
}
|
||||
/// Load and authorise user from the Config database
|
||||
switch (loginDlgBench.Method)
|
||||
{
|
||||
default:
|
||||
case Config.Entities.LoginMethod.UserName:
|
||||
loadedUser = Config.Entities.User.LoadUserByName(loginDlgBench.Alias, LocalSettings.TestBenches[i].ProceduresDBSettings);
|
||||
if (loadedUser != null) authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password);
|
||||
break;
|
||||
case Config.Entities.LoginMethod.FullName:
|
||||
loadedUser = Config.Entities.User.LoadUserByFullName(loginDlgBench.Alias, LocalSettings.TestBenches[i].ProceduresDBSettings);
|
||||
if (loadedUser != null) authorized = loadedUser.AuthorizeFullName(loginDlgBench.Alias, loginDlgBench.Password);
|
||||
break;
|
||||
case Config.Entities.LoginMethod.Number:
|
||||
int number;
|
||||
if (!int.TryParse(loginDlgBench.Alias, out number)) break;
|
||||
loadedUser = Config.Entities.User.LoadUserByNumber(number, LocalSettings.TestBenches[i].ProceduresDBSettings);
|
||||
if (loadedUser != null) authorized = loadedUser.AuthorizeNumber(number, loginDlgBench.Password);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (authorized)
|
||||
{
|
||||
|
||||
18
TestBenchFramework/Resources/Strings.Designer.cs
generated
18
TestBenchFramework/Resources/Strings.Designer.cs
generated
@ -1509,6 +1509,15 @@ namespace TBF.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Full name.
|
||||
/// </summary>
|
||||
internal static string Full_name {
|
||||
get {
|
||||
return ResourceManager.GetString("Full_name", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to General.
|
||||
/// </summary>
|
||||
@ -4302,6 +4311,15 @@ namespace TBF.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to User code.
|
||||
/// </summary>
|
||||
internal static string User_code {
|
||||
get {
|
||||
return ResourceManager.GetString("User_code", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to User Login.
|
||||
/// </summary>
|
||||
|
||||
@ -1284,4 +1284,10 @@
|
||||
<data name="Do_you_want_to_save_changes" xml:space="preserve">
|
||||
<value>Chcete uložit změny?</value>
|
||||
</data>
|
||||
<data name="Full_name" xml:space="preserve">
|
||||
<value>Jméno a příjmení</value>
|
||||
</data>
|
||||
<data name="User_code" xml:space="preserve">
|
||||
<value>Kód uživatele</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -1618,4 +1618,10 @@
|
||||
<data name="Users" xml:space="preserve">
|
||||
<value>Users</value>
|
||||
</data>
|
||||
<data name="Full_name" xml:space="preserve">
|
||||
<value>Full name</value>
|
||||
</data>
|
||||
<data name="User_code" xml:space="preserve">
|
||||
<value>User code</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -159,7 +159,7 @@ namespace TBF.UiControls
|
||||
newProcedure.Revision = 1;
|
||||
newProcedure.PredecessorId = 0;
|
||||
newProcedure.ObtainedByCopy = false;
|
||||
newProcedure.CreationUser = Config.Data.CurrentUser.Name;
|
||||
newProcedure.CreationUser = Config.Data.CurrentUser.UserName;
|
||||
newProcedure.CreationTime = DateTime.Now;
|
||||
|
||||
if (new ProcedureDlg(newProcedure).ShowDialog() == DialogResult.OK)
|
||||
@ -171,7 +171,7 @@ namespace TBF.UiControls
|
||||
{
|
||||
try
|
||||
{
|
||||
newProcedure.LastChgUser = Config.Data.CurrentUser.Name;
|
||||
newProcedure.LastChgUser = Config.Data.CurrentUser.UserName;
|
||||
newProcedure.LastChgTime = DateTime.Now;
|
||||
|
||||
base.AddOne(newProcedure);
|
||||
@ -240,7 +240,7 @@ namespace TBF.UiControls
|
||||
try
|
||||
{
|
||||
originalProcedure.ProcedureState = ProcedureState.History;
|
||||
modifiedProcedure.LastChgUser = Config.Data.CurrentUser.Name;
|
||||
modifiedProcedure.LastChgUser = Config.Data.CurrentUser.UserName;
|
||||
modifiedProcedure.LastChgTime = DateTime.Now;
|
||||
|
||||
session.SaveOrUpdate(originalProcedure);
|
||||
@ -280,7 +280,7 @@ namespace TBF.UiControls
|
||||
newProcedure.Revision = 1;
|
||||
newProcedure.PredecessorId = selectedProcedure.Id;
|
||||
newProcedure.ObtainedByCopy = true;
|
||||
newProcedure.CreationUser = Config.Data.CurrentUser.Name;
|
||||
newProcedure.CreationUser = Config.Data.CurrentUser.UserName;
|
||||
newProcedure.CreationTime = DateTime.Now;
|
||||
|
||||
if ((new ProcedureDlg(newProcedure)).ShowDialog() == DialogResult.OK)
|
||||
@ -290,7 +290,7 @@ namespace TBF.UiControls
|
||||
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
newProcedure.LastChgUser = Config.Data.CurrentUser.Name;
|
||||
newProcedure.LastChgUser = Config.Data.CurrentUser.UserName;
|
||||
newProcedure.LastChgTime = DateTime.Now;
|
||||
|
||||
base.AddOne(newProcedure);
|
||||
|
||||
@ -236,7 +236,7 @@ namespace TBF.UiControls
|
||||
}
|
||||
else if (Program.LocalSettings.AlwaysAskPasswdWhenUnlocking)
|
||||
{
|
||||
if ((new Forms.LoginDlg(Config.Data.CurrentUser.Name, RequiredGroupMembership)).ShowDialog() != DialogResult.OK) return;
|
||||
if ((new Forms.LoginDlg(Config.Data.CurrentUser.UserName, RequiredGroupMembership)).ShowDialog() != DialogResult.OK) return;
|
||||
}
|
||||
|
||||
UnlockButtons();
|
||||
|
||||
@ -16,11 +16,10 @@ namespace Users.Entities
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(User));
|
||||
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string UserName { get; set; } /// = name, alias, abbreviation
|
||||
public virtual string FullName { get; set; } /// = description
|
||||
public virtual int Number { get; set; }
|
||||
public virtual string Alias { get; set; }
|
||||
public virtual string Password { get; set; }
|
||||
public virtual string Description { get; set; }
|
||||
public virtual DateTime LastPwChange { get; set; }
|
||||
public virtual IList<Group> Groups { get; set; } //User can be a member of a list of groups
|
||||
|
||||
@ -33,13 +32,13 @@ namespace Users.Entities
|
||||
Number = 0;
|
||||
}
|
||||
|
||||
public User(string name, int number, bool powerUser)
|
||||
public User(string userName, int number, bool powerUser)
|
||||
{
|
||||
Name = name;
|
||||
UserName = userName;
|
||||
Number = number;
|
||||
this.powerUser = powerUser;
|
||||
Groups = new List<Group>();
|
||||
Description = powerUser ? "Power user" : string.Empty;
|
||||
FullName = powerUser ? "Power user" : string.Empty;
|
||||
}
|
||||
|
||||
public virtual void AddGroup(Group group)
|
||||
@ -105,6 +104,7 @@ namespace Users.Entities
|
||||
return (Password == EncryptedPassword(password));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The FIRST of TWO possible user authorization method to be used
|
||||
/// when a specific group membership is required (you can use Grp.GID.None).
|
||||
@ -112,9 +112,9 @@ namespace Users.Entities
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="requiredGrupMembership"></param>
|
||||
/// <param name="userName">User name</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <param name="requiredGrupMembership"></param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool Authorize(string userName, string password, Grp.GID requiredGroupMembership)
|
||||
{
|
||||
@ -126,7 +126,7 @@ namespace Users.Entities
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Name.ToLower() == userName.ToLower())
|
||||
if (UserName.ToLower() == userName.ToLower())
|
||||
{
|
||||
if (IsMemberOf(requiredGroupMembership) && CheckPassword(password))
|
||||
{
|
||||
@ -143,6 +143,15 @@ namespace Users.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// </summary>
|
||||
public virtual bool Authorize(string userName, string password)
|
||||
{
|
||||
return Authorize(userName, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The FIRST of TWO possible user authorization method to be used
|
||||
/// when a specific group membership is required (you can use Grp.GID.None).
|
||||
@ -150,8 +159,8 @@ namespace Users.Entities
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="number">User ID number</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <param name="requiredGrupMembership"></param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool AuthorizeNumber(int number, string password, Grp.GID requiredGroupMembership)
|
||||
@ -173,6 +182,15 @@ namespace Users.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// </summary>
|
||||
public virtual bool AuthorizeNumber(int number, string password)
|
||||
{
|
||||
return AuthorizeNumber(number, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The FIRST of TWO possible user authorization method to be used
|
||||
/// when a specific group membership is required (you can use Grp.GID.None).
|
||||
@ -180,19 +198,19 @@ namespace Users.Entities
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="alias"></param>
|
||||
/// <param name="fullName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="requiredGrupMembership"></param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool AuthorizeAlias(string alias, string password, Grp.GID requiredGroupMembership)
|
||||
public virtual bool AuthorizeFullName(string fullName, string password, Grp.GID requiredGroupMembership)
|
||||
{
|
||||
if (Alias.ToLower() == alias.ToLower())
|
||||
if (FullName.ToLower() == fullName.ToLower())
|
||||
{
|
||||
if (IsMemberOf(requiredGroupMembership) && CheckPassword(password))
|
||||
{
|
||||
Data.CurrentUser = this;
|
||||
Data.LastAuthorization = DateTime.Now;
|
||||
log.FatalFormat("User alias={0} authorized @level '{1}'", alias, requiredGroupMembership);
|
||||
log.FatalFormat("User alias={0} authorized @level '{1}'", fullName, requiredGroupMembership);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -203,50 +221,15 @@ namespace Users.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="userName">User name</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool Authorize(string userName, string password)
|
||||
{
|
||||
return Authorize(userName, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="number">User ID number</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool AuthorizeNumber(int number, string password)
|
||||
public virtual bool AuthorizeFullName(string fullName, string password)
|
||||
{
|
||||
return AuthorizeNumber(number, password, Grp.GID.None);
|
||||
return AuthorizeFullName(fullName, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="userName">Alias (abbreviated user name)</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool AuthorizeAlias(string alias, string password)
|
||||
{
|
||||
return AuthorizeAlias(alias, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from a database.
|
||||
@ -256,24 +239,25 @@ namespace Users.Entities
|
||||
public static User AuthorizeDummyUser(string username)
|
||||
{
|
||||
User user = new User();
|
||||
user.Name = username;
|
||||
user.UserName = username;
|
||||
Data.CurrentUser = user;
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from an ARBITRARY database.
|
||||
/// </summary>
|
||||
/// <param name="username">User name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByName(string username, Config.DBSettings dbSettings)
|
||||
public static User LoadUserByName(string userName, Config.DBSettings dbSettings)
|
||||
{
|
||||
DB.DbType = dbSettings.DbType;
|
||||
DB.ConnectionString = dbSettings.ConnectionString;
|
||||
IList<User> listOfUsers = DB.CreateSession()
|
||||
.QueryOver<User>()
|
||||
.Where(x => (x.Name.ToLower() == username.ToLower()))
|
||||
.List();
|
||||
.CreateQuery("FROM User WHERE LOWER(UserName) = :username") /// Note: QueryOver<User>().Where(x => x.UserName.ToLower() == ... does not work
|
||||
.SetParameter("username", userName.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
@ -283,16 +267,84 @@ namespace Users.Entities
|
||||
/// </summary>
|
||||
/// <param name="username">User name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByName(string username)
|
||||
public static User LoadUserByName(string userName)
|
||||
{
|
||||
string upperCaseUserName = userName.ToUpper();
|
||||
IList<User> listOfUsers = DB.CreateSession()
|
||||
.CreateQuery("FROM User WHERE LOWER(UserName) = :username") /// Note: QueryOver<User>().Where(x => x.UserName.ToLower() == ... does not work
|
||||
.SetParameter("username", userName.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given full name from an ARBITRARY database.
|
||||
/// </summary>
|
||||
/// <param name="fullName">Full name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByFullName(string fullName, Config.DBSettings dbSettings)
|
||||
{
|
||||
DB.DbType = dbSettings.DbType;
|
||||
DB.ConnectionString = dbSettings.ConnectionString;
|
||||
IList<User> listOfUsers = DB.CreateSession()
|
||||
.CreateQuery("FROM User WHERE LOWER(Description) = :fullname") /// Note: QueryOver<User>().Where(x => x.FullName.ToLower() == ... does not work
|
||||
.SetParameter("fullname", fullName.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given full name from the users database.
|
||||
/// </summary>
|
||||
/// <param name="fullName">Full name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByFullName(string fullName)
|
||||
{
|
||||
IList<User> listOfUsers = DB.CreateSession()
|
||||
.QueryOver<User>()
|
||||
.Where(x => (x.Name.ToLower() == username.ToLower()))
|
||||
.List();
|
||||
.CreateQuery("FROM User WHERE LOWER(Description) = :fullname") /// Note: QueryOver<User>().Where(x => x.FullName.ToLower() == ... does not work
|
||||
.SetParameter("fullname", fullName.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from an ARBITRARY database.
|
||||
/// </summary>
|
||||
/// <param name="number">User ID number for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByNumber(int number, Config.DBSettings dbSettings)
|
||||
{
|
||||
DB.DbType = dbSettings.DbType;
|
||||
DB.ConnectionString = dbSettings.ConnectionString;
|
||||
IList<User> listOfUsers = DB.CreateSession()
|
||||
.QueryOver<User>()
|
||||
.Where(x => (x.Number == number))
|
||||
.List();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from the users database.
|
||||
/// </summary>
|
||||
/// <param name="number">User ID number for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByNumber(int number)
|
||||
{
|
||||
IList<User> listOfUsers = DB.CreateSession()
|
||||
.QueryOver<User>()
|
||||
.Where(x => (x.Number == number))
|
||||
.List();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// returns an IList of all Users
|
||||
/// </summary>
|
||||
|
||||
@ -10,11 +10,11 @@ namespace Users.Mappings
|
||||
public UserMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.UserName).Column("Name");
|
||||
Map(x => x.Number);
|
||||
Map(x => x.Password);
|
||||
Map(x => x.Description);
|
||||
Map(x => x.LastPwChange);
|
||||
Map(x => x.FullName).Column("Description");
|
||||
Map(x => x.LastPwChange);
|
||||
HasMany(x => x.Groups)
|
||||
.Cascade.All();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user