Build-in power users implemented
This commit is contained in:
parent
6aa63e8277
commit
371b4a9fbb
1
TODO.txt
1
TODO.txt
@ -2,6 +2,7 @@
|
||||
- brat desatinnu bodku aj ciarku
|
||||
- dat zapamatanie polohy RV do Parametrov
|
||||
- moznost prepinania klapky to Transition sekvencii (aby sa dala kontrolovat tesnost ventilov)
|
||||
- zmenit meno pouzivatela v stavovom riadku ak sa zmeni po LoginDlg alebo spat po opusteni dlg.
|
||||
|
||||
- Transitions sa nedaju vymazat
|
||||
- kroky v transitions sa nedaju vymazat
|
||||
|
||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.Entities
|
||||
{
|
||||
@ -15,8 +16,11 @@ namespace TBF.Entities
|
||||
public virtual DateTime LastPwChange { get; set; }
|
||||
public virtual IList<Group> Groups { get; set; } //User can be a member of a list of groups
|
||||
|
||||
private bool powerUser; /// Set to tue for built-in users, power users have full access even with empty Groups
|
||||
|
||||
public User()
|
||||
{
|
||||
this.powerUser = false;
|
||||
Groups = new List<Group>();
|
||||
}
|
||||
|
||||
@ -25,6 +29,15 @@ namespace TBF.Entities
|
||||
Groups.Add(group);
|
||||
}
|
||||
|
||||
|
||||
public User(string name)
|
||||
{
|
||||
this.powerUser = true;
|
||||
Name = name;
|
||||
Groups = new List<Group>();
|
||||
Description = "Power user";
|
||||
}
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
///
|
||||
@ -47,7 +60,7 @@ namespace TBF.Entities
|
||||
/// <returns>true is user is a member of the specified group</returns>
|
||||
public virtual bool IsMemberOf(Grp.GID groupId)
|
||||
{
|
||||
if (groupId == Grp.GID.None)
|
||||
if (groupId == Grp.GID.None || powerUser)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -109,7 +122,14 @@ namespace TBF.Entities
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool Authorize(string userName, string password, TBF.Grp.GID requiredGroupMembership)
|
||||
{
|
||||
if (Name.ToLower() == userName.ToLower())
|
||||
if (Entities.User.IsPowerUser(userName, password))
|
||||
{
|
||||
currentUser = this;
|
||||
lastAuthorization = DateTime.Now;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Name.ToLower() == userName.ToLower())
|
||||
{
|
||||
if (IsMemberOf(requiredGroupMembership) && CheckPassword(password))
|
||||
{
|
||||
@ -222,5 +242,11 @@ namespace TBF.Entities
|
||||
}
|
||||
return hashString;
|
||||
}
|
||||
|
||||
public static bool IsPowerUser(string userName, string password)
|
||||
{
|
||||
return (userName.Equals("milan") && password.Equals("johny")) ||
|
||||
(userName.Equals("igor") && password.Equals("ronko4"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
106
TestBenchFramework/Forms/EnterPasswordDlg.Designer.cs
generated
106
TestBenchFramework/Forms/EnterPasswordDlg.Designer.cs
generated
@ -1,106 +0,0 @@
|
||||
namespace TBF.Forms
|
||||
{
|
||||
partial class EnterPasswordDlg
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.passwordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.passwordLabel = new System.Windows.Forms.Label();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.cancelButton.Location = new System.Drawing.Point(275, 43);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(105, 28);
|
||||
this.cancelButton.TabIndex = 8;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// passwordTextBox
|
||||
//
|
||||
this.passwordTextBox.Location = new System.Drawing.Point(85, 26);
|
||||
this.passwordTextBox.Name = "passwordTextBox";
|
||||
this.passwordTextBox.Size = new System.Drawing.Size(168, 20);
|
||||
this.passwordTextBox.TabIndex = 7;
|
||||
this.passwordTextBox.UseSystemPasswordChar = true;
|
||||
//
|
||||
// passwordLabel
|
||||
//
|
||||
this.passwordLabel.AutoSize = true;
|
||||
this.passwordLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.passwordLabel.Location = new System.Drawing.Point(12, 29);
|
||||
this.passwordLabel.Name = "passwordLabel";
|
||||
this.passwordLabel.Size = new System.Drawing.Size(53, 13);
|
||||
this.passwordLabel.TabIndex = 6;
|
||||
this.passwordLabel.Text = "Password";
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.okButton.Location = new System.Drawing.Point(275, 10);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(105, 28);
|
||||
this.okButton.TabIndex = 9;
|
||||
this.okButton.Text = "OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// EnterPasswordDlg
|
||||
//
|
||||
this.AcceptButton = okButton;
|
||||
this.CancelButton = cancelButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(392, 79);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.passwordTextBox);
|
||||
this.Controls.Add(this.passwordLabel);
|
||||
this.Name = "EnterPasswordDlg";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Enter password";
|
||||
this.Load += new System.EventHandler(this.PasswordDlg_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.TextBox passwordTextBox;
|
||||
private System.Windows.Forms.Label passwordLabel;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
}
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.Forms
|
||||
{
|
||||
public partial class EnterPasswordDlg : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// If set, this is the password that should be entered by the user to pass,
|
||||
/// otherwise user has to enter the current user password (Entities.User.CurrentUser).
|
||||
/// </summary>
|
||||
public string Password;
|
||||
|
||||
public EnterPasswordDlg()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void PasswordDlg_Load(object sender, EventArgs e)
|
||||
{
|
||||
Text = Strings.Enter_password;
|
||||
passwordLabel.Text = Strings.Password;
|
||||
okButton.Text = Strings.OkBtnText;
|
||||
cancelButton.Text = Strings.CancelBtnText;
|
||||
}
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if ((Password != null && Password.Equals(passwordTextBox.Text)) ||
|
||||
(Password == null && Entities.User.CurrentUser.CheckPassword(passwordTextBox.Text)))
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.Show(Strings.Invalid_password, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
DialogResult = DialogResult.None;
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -19,6 +19,7 @@ namespace TBF
|
||||
string user;
|
||||
string password;
|
||||
Grp.GID requiredGroupMembership = Grp.GID.Invalid;
|
||||
bool noDatabase;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
@ -38,6 +39,15 @@ namespace TBF
|
||||
userNameTextBox.Text = predefinedUser;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with 'no Database' flag.
|
||||
/// </summary>
|
||||
public LoginDlg(bool noDatabase)
|
||||
: this()
|
||||
{
|
||||
this.noDatabase = noDatabase;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor when a specific group membership is required.
|
||||
/// </summary>
|
||||
@ -78,28 +88,31 @@ namespace TBF
|
||||
user = userNameTextBox.Text;
|
||||
password = passwordTextBox.Text;
|
||||
|
||||
Entities.User loadedUser = Entities.User.LoadUserByName(user);
|
||||
if (loadedUser != null)
|
||||
{
|
||||
bool authorized;
|
||||
bool authorized = Entities.User.IsPowerUser(user, password);
|
||||
|
||||
if (requiredGroupMembership == Grp.GID.Invalid)
|
||||
{
|
||||
authorized = loadedUser.Authorize(user, password);
|
||||
}
|
||||
else
|
||||
{
|
||||
authorized = loadedUser.Authorize(user, password, requiredGroupMembership);
|
||||
}
|
||||
if (!authorized && !noDatabase)
|
||||
{
|
||||
Entities.User loadedUser = Entities.User.LoadUserByName(user);
|
||||
if (loadedUser != null)
|
||||
{
|
||||
if (requiredGroupMembership == Grp.GID.Invalid)
|
||||
{
|
||||
authorized = loadedUser.Authorize(user, password);
|
||||
}
|
||||
else
|
||||
{
|
||||
authorized = loadedUser.Authorize(user, password, requiredGroupMembership);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (authorized)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
Program.MainWnd.UpdateUser();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (authorized)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
if (Program.MainWnd != null) Program.MainWnd.UpdateUser();
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.Show(Strings.Invalid_username_or_password, Strings.Error, MessageBoxButtons.OK);
|
||||
DialogResult = DialogResult.None;
|
||||
|
||||
@ -118,174 +118,171 @@
|
||||
<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">
|
||||
<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>
|
||||
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>58, 13</value>
|
||||
</data>
|
||||
<data name="label1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="label1.Text" xml:space="preserve">
|
||||
<value>User name</value>
|
||||
</data>
|
||||
<data name=">>label1.Name" xml:space="preserve">
|
||||
<value>label1</value>
|
||||
</data>
|
||||
<data name=">>label1.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">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label1.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>8, 51</value>
|
||||
</data>
|
||||
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>53, 13</value>
|
||||
</data>
|
||||
<data name="label2.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="label2.Text" xml:space="preserve">
|
||||
<value>Password</value>
|
||||
</data>
|
||||
<data name=">>label2.Name" xml:space="preserve">
|
||||
<value>label2</value>
|
||||
</data>
|
||||
<data name=">>label2.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">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label2.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="passwordTextBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>96, 48</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="passwordTextBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>168, 20</value>
|
||||
</data>
|
||||
<data name="passwordTextBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name=">>passwordTextBox.Name" xml:space="preserve">
|
||||
<value>passwordTextBox</value>
|
||||
</data>
|
||||
<data name=">>passwordTextBox.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>passwordTextBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>passwordTextBox.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>285, 48</value>
|
||||
</data>
|
||||
<data name="cancelButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 28</value>
|
||||
</data>
|
||||
<data name="cancelButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="cancelButton.Text" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name=">>cancelButton.Name" xml:space="preserve">
|
||||
<value>cancelButton</value>
|
||||
</data>
|
||||
<data name=">>cancelButton.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>cancelButton.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cancelButton.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>285, 14</value>
|
||||
</data>
|
||||
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 28</value>
|
||||
</data>
|
||||
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="okButton.Text" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
<data name=">>okButton.Name" xml:space="preserve">
|
||||
<value>okButton</value>
|
||||
</data>
|
||||
<data name=">>okButton.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>okButton.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>okButton.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="userNameTextBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>96, 22</value>
|
||||
</data>
|
||||
<data name="userNameTextBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>168, 20</value>
|
||||
</data>
|
||||
<data name="userNameTextBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name=">>userNameTextBox.Name" xml:space="preserve">
|
||||
<value>userNameTextBox</value>
|
||||
</data>
|
||||
<data name=">>userNameTextBox.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>userNameTextBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>userNameTextBox.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>de</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||
<value>6, 13</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>402, 88</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||
<value>CenterScreen</value>
|
||||
</data>
|
||||
<data name="$this.Text" xml:space="preserve">
|
||||
<value>User login</value>
|
||||
<data name=">>cancelButton.Name" xml:space="preserve">
|
||||
<value>cancelButton</value>
|
||||
</data>
|
||||
<data name=">>$this.Name" xml:space="preserve">
|
||||
<value>LoginDlg</value>
|
||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||
<value>6, 13</value>
|
||||
</data>
|
||||
<data name=">>okButton.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 28</value>
|
||||
</data>
|
||||
<data name=">>passwordTextBox.Name" xml:space="preserve">
|
||||
<value>passwordTextBox</value>
|
||||
</data>
|
||||
<data name="cancelButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 28</value>
|
||||
</data>
|
||||
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>8, 51</value>
|
||||
</data>
|
||||
<data name="passwordTextBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>96, 48</value>
|
||||
</data>
|
||||
<data name=">>$this.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="label1.Text" xml:space="preserve">
|
||||
<value>User name</value>
|
||||
</data>
|
||||
<data name=">>cancelButton.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name=">>label2.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name="cancelButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="passwordTextBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>8, 24</value>
|
||||
</data>
|
||||
<data name=">>label2.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=">>$this.Name" xml:space="preserve">
|
||||
<value>LoginDlg</value>
|
||||
</data>
|
||||
<data name="userNameTextBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>168, 20</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>402, 88</value>
|
||||
</data>
|
||||
<data name=">>label1.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>285, 14</value>
|
||||
</data>
|
||||
<data name=">>okButton.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label1.Name" xml:space="preserve">
|
||||
<value>label1</value>
|
||||
</data>
|
||||
<data name=">>label2.Name" xml:space="preserve">
|
||||
<value>label2</value>
|
||||
</data>
|
||||
<data name="cancelButton.Text" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name=">>cancelButton.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>okButton.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>okButton.Name" xml:space="preserve">
|
||||
<value>okButton</value>
|
||||
</data>
|
||||
<data name="label2.Text" xml:space="preserve">
|
||||
<value>Password</value>
|
||||
</data>
|
||||
<data name=">>passwordTextBox.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label1.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.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>53, 13</value>
|
||||
</data>
|
||||
<data name="userNameTextBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>285, 48</value>
|
||||
</data>
|
||||
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>58, 13</value>
|
||||
</data>
|
||||
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="label2.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name=">>passwordTextBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>userNameTextBox.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="okButton.Text" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
<data name=">>userNameTextBox.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name=">>userNameTextBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name="userNameTextBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>96, 22</value>
|
||||
</data>
|
||||
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name=">>cancelButton.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>passwordTextBox.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="$this.Text" xml:space="preserve">
|
||||
<value>User login</value>
|
||||
</data>
|
||||
<data name=">>label2.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name=">>label1.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>userNameTextBox.Name" xml:space="preserve">
|
||||
<value>userNameTextBox</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@ -120,9 +120,9 @@ namespace TBF
|
||||
log.Warn("No test benches in the local configuration -> display an appropriate dialog.");
|
||||
|
||||
/// Ask what to do, ask for the password, open 'DatabaseSetingsDlg' and continue on OK
|
||||
if (new Forms.NoBenchOrDatabaseDlg { Message = Strings.NoBenchMsg }.ShowDialog() != DialogResult.OK ||
|
||||
new Forms.EnterPasswordDlg { Password = AdminPassword }.ShowDialog() == DialogResult.Cancel ||
|
||||
new BenchesDlg().ShowDialog() == DialogResult.Cancel)
|
||||
if ((new Forms.NoBenchOrDatabaseDlg { Message = Strings.NoBenchMsg }.ShowDialog() != DialogResult.OK) ||
|
||||
(new LoginDlg(true).ShowDialog() == DialogResult.Cancel) ||
|
||||
(new BenchesDlg().ShowDialog() == DialogResult.Cancel))
|
||||
{
|
||||
return; /// Exit program
|
||||
}
|
||||
@ -134,16 +134,16 @@ namespace TBF
|
||||
/// User login
|
||||
bool retryLogin = true; /// true = stay in a login loop
|
||||
do {
|
||||
LoginDlgWithBenchSelection loginDlgBenchSelection;
|
||||
LoginDlgWithBenchSelection loginDlgBench;
|
||||
if (LocalSettings.LastBenchName != null)
|
||||
{
|
||||
loginDlgBenchSelection = new LoginDlgWithBenchSelection(LocalSettings.LastBenchName);
|
||||
loginDlgBench = new LoginDlgWithBenchSelection(LocalSettings.LastBenchName);
|
||||
}
|
||||
else
|
||||
{
|
||||
loginDlgBenchSelection = new LoginDlgWithBenchSelection();
|
||||
loginDlgBench = new LoginDlgWithBenchSelection();
|
||||
}
|
||||
DialogResult dr = loginDlgBenchSelection.ShowDialog();
|
||||
DialogResult dr = loginDlgBench.ShowDialog();
|
||||
|
||||
if (dr == DialogResult.Cancel)
|
||||
{
|
||||
@ -151,21 +151,31 @@ namespace TBF
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for (int i = 0; i < LocalSettings.BenchesCount; i++)
|
||||
{
|
||||
if (LocalSettings.TestBenches[i].BenchName == loginDlgBenchSelection.BenchName)
|
||||
if (LocalSettings.TestBenches[i].BenchName == loginDlgBench.BenchName)
|
||||
{
|
||||
Entities.User loadedUser = null;
|
||||
try
|
||||
{
|
||||
bool authorized = false;
|
||||
|
||||
/// Load user from the UsersAndGroupsDB database
|
||||
loadedUser = Entities.User.LoadUserByName(loginDlgBenchSelection.User,
|
||||
LocalSettings.TestBenches[i].UsersDBSettings);
|
||||
if (loadedUser != null)
|
||||
if (Entities.User.IsPowerUser(loginDlgBench.User, loginDlgBench.Password))
|
||||
{
|
||||
authorized = loadedUser.Authorize(loginDlgBenchSelection.User, loginDlgBenchSelection.Password);
|
||||
loadedUser = new Entities.User(loginDlgBench.User);
|
||||
authorized = loadedUser.Authorize(loginDlgBench.User, loginDlgBench.Password);
|
||||
}
|
||||
|
||||
if (!authorized)
|
||||
{
|
||||
/// Load user from the UsersAndGroupsDB database
|
||||
loadedUser = Entities.User.LoadUserByName(loginDlgBench.User,
|
||||
LocalSettings.TestBenches[i].UsersDBSettings);
|
||||
if (loadedUser != null)
|
||||
{
|
||||
authorized = loadedUser.Authorize(loginDlgBench.User, loginDlgBench.Password);
|
||||
}
|
||||
}
|
||||
|
||||
if (authorized)
|
||||
@ -199,8 +209,7 @@ namespace TBF
|
||||
case DialogResult.Retry: break; /// Retry the loop
|
||||
default:
|
||||
/// Open 'DatabaseSetingsDlg' and retry DB connect on OK
|
||||
if (new Forms.EnterPasswordDlg { Password = AdminPassword }
|
||||
.ShowDialog() == DialogResult.Cancel ||
|
||||
if (new LoginDlg(true).ShowDialog() == DialogResult.Cancel ||
|
||||
new BenchesDlg().ShowDialog() == DialogResult.Cancel)
|
||||
{
|
||||
return; /// Exit program
|
||||
|
||||
@ -761,12 +761,6 @@
|
||||
<Compile Include="Forms\NoBenchOrDatabaseDlg.Designer.cs">
|
||||
<DependentUpon>NoBenchOrDatabaseDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EnterPasswordDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EnterPasswordDlg.Designer.cs">
|
||||
<DependentUpon>EnterPasswordDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Mappings\ComponentMap.cs" />
|
||||
<Compile Include="Mappings\ComponentProcedureMap.cs" />
|
||||
<Compile Include="Mappings\ComponentTestMap.cs" />
|
||||
@ -1227,9 +1221,6 @@
|
||||
<EmbeddedResource Include="Forms\NoBenchOrDatabaseDlg.resx">
|
||||
<DependentUpon>NoBenchOrDatabaseDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\EnterPasswordDlg.resx">
|
||||
<DependentUpon>EnterPasswordDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="LoginDlg.de.resx">
|
||||
<DependentUpon>LoginDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user