login!
This commit is contained in:
184
OwnChar.App.Desktop/UI/MainTabs/TabLoginView.Designer.cs
generated
184
OwnChar.App.Desktop/UI/MainTabs/TabLoginView.Designer.cs
generated
@@ -29,18 +29,26 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
radButton1 = new Telerik.WinControls.UI.RadButton();
|
||||
radLabel1 = new Telerik.WinControls.UI.RadLabel();
|
||||
radTextBoxControl1 = new Telerik.WinControls.UI.RadTextBoxControl();
|
||||
radTextBoxControl2 = new Telerik.WinControls.UI.RadTextBoxControl();
|
||||
radTextBoxControl_Password = new Telerik.WinControls.UI.RadTextBoxControl();
|
||||
radLabel2 = new Telerik.WinControls.UI.RadLabel();
|
||||
radTextBoxControl_Username = new Telerik.WinControls.UI.RadTextBoxControl();
|
||||
radButton_Login = new Telerik.WinControls.UI.RadButton();
|
||||
radLabel1 = new Telerik.WinControls.UI.RadLabel();
|
||||
radLabel3 = new Telerik.WinControls.UI.RadLabel();
|
||||
tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
|
||||
radDropDownList_LoginProvider = new Telerik.WinControls.UI.RadDropDownList();
|
||||
radButton_ConfigureProvider = new Telerik.WinControls.UI.RadButton();
|
||||
tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||
tableLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radButton1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl2).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl_Password).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel2).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl_Username).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radButton_Login).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel3).BeginInit();
|
||||
tableLayoutPanel3.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radDropDownList_LoginProvider).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radButton_ConfigureProvider).BeginInit();
|
||||
tableLayoutPanel2.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@@ -51,64 +59,116 @@
|
||||
tableLayoutPanel1.ColumnCount = 2;
|
||||
tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 40F));
|
||||
tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 60F));
|
||||
tableLayoutPanel1.Controls.Add(radTextBoxControl2, 1, 1);
|
||||
tableLayoutPanel1.Controls.Add(radLabel2, 0, 1);
|
||||
tableLayoutPanel1.Controls.Add(radTextBoxControl1, 1, 0);
|
||||
tableLayoutPanel1.Controls.Add(radButton1, 1, 2);
|
||||
tableLayoutPanel1.Controls.Add(radLabel1, 0, 0);
|
||||
tableLayoutPanel1.Location = new System.Drawing.Point(129, 81);
|
||||
tableLayoutPanel1.Controls.Add(radTextBoxControl_Password, 1, 2);
|
||||
tableLayoutPanel1.Controls.Add(radLabel2, 0, 2);
|
||||
tableLayoutPanel1.Controls.Add(radTextBoxControl_Username, 1, 1);
|
||||
tableLayoutPanel1.Controls.Add(radButton_Login, 1, 3);
|
||||
tableLayoutPanel1.Controls.Add(radLabel1, 0, 1);
|
||||
tableLayoutPanel1.Controls.Add(radLabel3, 0, 0);
|
||||
tableLayoutPanel1.Controls.Add(tableLayoutPanel3, 1, 0);
|
||||
tableLayoutPanel1.Location = new System.Drawing.Point(129, 74);
|
||||
tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
|
||||
tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
tableLayoutPanel1.RowCount = 3;
|
||||
tableLayoutPanel1.RowCount = 4;
|
||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
tableLayoutPanel1.Size = new System.Drawing.Size(259, 86);
|
||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
tableLayoutPanel1.Size = new System.Drawing.Size(259, 114);
|
||||
tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// radButton1
|
||||
// radTextBoxControl_Password
|
||||
//
|
||||
radButton1.Location = new System.Drawing.Point(106, 59);
|
||||
radButton1.Name = "radButton1";
|
||||
radButton1.Size = new System.Drawing.Size(110, 24);
|
||||
radButton1.TabIndex = 1;
|
||||
radButton1.Text = "radButton1";
|
||||
//
|
||||
// radLabel1
|
||||
//
|
||||
radLabel1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radLabel1.AutoSize = false;
|
||||
radLabel1.Location = new System.Drawing.Point(3, 3);
|
||||
radLabel1.Name = "radLabel1";
|
||||
radLabel1.Size = new System.Drawing.Size(97, 22);
|
||||
radLabel1.TabIndex = 1;
|
||||
radLabel1.Text = "radLabel1";
|
||||
//
|
||||
// radTextBoxControl1
|
||||
//
|
||||
radTextBoxControl1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radTextBoxControl1.Location = new System.Drawing.Point(106, 3);
|
||||
radTextBoxControl1.Name = "radTextBoxControl1";
|
||||
radTextBoxControl1.Size = new System.Drawing.Size(150, 22);
|
||||
radTextBoxControl1.TabIndex = 2;
|
||||
//
|
||||
// radTextBoxControl2
|
||||
//
|
||||
radTextBoxControl2.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radTextBoxControl2.Location = new System.Drawing.Point(106, 31);
|
||||
radTextBoxControl2.Name = "radTextBoxControl2";
|
||||
radTextBoxControl2.Size = new System.Drawing.Size(150, 22);
|
||||
radTextBoxControl2.TabIndex = 1;
|
||||
radTextBoxControl_Password.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radTextBoxControl_Password.Location = new System.Drawing.Point(106, 59);
|
||||
radTextBoxControl_Password.Name = "radTextBoxControl_Password";
|
||||
radTextBoxControl_Password.Size = new System.Drawing.Size(150, 22);
|
||||
radTextBoxControl_Password.TabIndex = 1;
|
||||
//
|
||||
// radLabel2
|
||||
//
|
||||
radLabel2.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radLabel2.AutoSize = false;
|
||||
radLabel2.Location = new System.Drawing.Point(3, 31);
|
||||
radLabel2.Location = new System.Drawing.Point(3, 59);
|
||||
radLabel2.Name = "radLabel2";
|
||||
radLabel2.Size = new System.Drawing.Size(97, 22);
|
||||
radLabel2.TabIndex = 0;
|
||||
radLabel2.Text = "radLabel2";
|
||||
radLabel2.Text = "Password";
|
||||
//
|
||||
// radTextBoxControl_Username
|
||||
//
|
||||
radTextBoxControl_Username.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radTextBoxControl_Username.Location = new System.Drawing.Point(106, 31);
|
||||
radTextBoxControl_Username.Name = "radTextBoxControl_Username";
|
||||
radTextBoxControl_Username.Size = new System.Drawing.Size(150, 22);
|
||||
radTextBoxControl_Username.TabIndex = 2;
|
||||
//
|
||||
// radButton_Login
|
||||
//
|
||||
radButton_Login.Location = new System.Drawing.Point(106, 87);
|
||||
radButton_Login.Name = "radButton_Login";
|
||||
radButton_Login.Size = new System.Drawing.Size(110, 24);
|
||||
radButton_Login.TabIndex = 1;
|
||||
radButton_Login.Text = "Login";
|
||||
radButton_Login.Click += RadButton_Login_Click;
|
||||
//
|
||||
// radLabel1
|
||||
//
|
||||
radLabel1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radLabel1.AutoSize = false;
|
||||
radLabel1.Location = new System.Drawing.Point(3, 31);
|
||||
radLabel1.Name = "radLabel1";
|
||||
radLabel1.Size = new System.Drawing.Size(97, 22);
|
||||
radLabel1.TabIndex = 1;
|
||||
radLabel1.Text = "Username";
|
||||
//
|
||||
// radLabel3
|
||||
//
|
||||
radLabel3.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radLabel3.AutoSize = false;
|
||||
radLabel3.Location = new System.Drawing.Point(3, 3);
|
||||
radLabel3.Name = "radLabel3";
|
||||
radLabel3.Size = new System.Drawing.Size(97, 22);
|
||||
radLabel3.TabIndex = 3;
|
||||
radLabel3.Text = "Provider";
|
||||
//
|
||||
// tableLayoutPanel3
|
||||
//
|
||||
tableLayoutPanel3.AutoSize = true;
|
||||
tableLayoutPanel3.ColumnCount = 2;
|
||||
tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
tableLayoutPanel3.Controls.Add(radDropDownList_LoginProvider, 0, 0);
|
||||
tableLayoutPanel3.Controls.Add(radButton_ConfigureProvider, 1, 0);
|
||||
tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
tableLayoutPanel3.Location = new System.Drawing.Point(103, 0);
|
||||
tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(0);
|
||||
tableLayoutPanel3.Name = "tableLayoutPanel3";
|
||||
tableLayoutPanel3.RowCount = 1;
|
||||
tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
tableLayoutPanel3.Size = new System.Drawing.Size(156, 28);
|
||||
tableLayoutPanel3.TabIndex = 4;
|
||||
//
|
||||
// radDropDownList_LoginProvider
|
||||
//
|
||||
radDropDownList_LoginProvider.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radDropDownList_LoginProvider.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
|
||||
radDropDownList_LoginProvider.Location = new System.Drawing.Point(3, 3);
|
||||
radDropDownList_LoginProvider.Name = "radDropDownList_LoginProvider";
|
||||
radDropDownList_LoginProvider.Size = new System.Drawing.Size(122, 22);
|
||||
radDropDownList_LoginProvider.TabIndex = 0;
|
||||
radDropDownList_LoginProvider.SelectedValueChanged += RadDropDownList_LoginProvider_SelectedValueChanged;
|
||||
//
|
||||
// radButton_ConfigureProvider
|
||||
//
|
||||
radButton_ConfigureProvider.DisplayStyle = Telerik.WinControls.DisplayStyle.Image;
|
||||
radButton_ConfigureProvider.ImageAlignment = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
radButton_ConfigureProvider.Location = new System.Drawing.Point(131, 3);
|
||||
radButton_ConfigureProvider.Name = "radButton_ConfigureProvider";
|
||||
radButton_ConfigureProvider.Size = new System.Drawing.Size(22, 22);
|
||||
radButton_ConfigureProvider.TabIndex = 1;
|
||||
radButton_ConfigureProvider.Text = "Configure";
|
||||
radButton_ConfigureProvider.Click += RadButton_ConfigureProvider_Click;
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
@@ -135,11 +195,17 @@
|
||||
Name = "TabLoginView";
|
||||
Size = new System.Drawing.Size(519, 412);
|
||||
tableLayoutPanel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)radButton1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl2).EndInit();
|
||||
tableLayoutPanel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl_Password).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel2).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl_Username).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radButton_Login).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel3).EndInit();
|
||||
tableLayoutPanel3.ResumeLayout(false);
|
||||
tableLayoutPanel3.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radDropDownList_LoginProvider).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radButton_ConfigureProvider).EndInit();
|
||||
tableLayoutPanel2.ResumeLayout(false);
|
||||
tableLayoutPanel2.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
@@ -148,11 +214,15 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl2;
|
||||
private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl_Password;
|
||||
private Telerik.WinControls.UI.RadLabel radLabel2;
|
||||
private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl1;
|
||||
private Telerik.WinControls.UI.RadButton radButton1;
|
||||
private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl_Username;
|
||||
private Telerik.WinControls.UI.RadButton radButton_Login;
|
||||
private Telerik.WinControls.UI.RadLabel radLabel1;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
|
||||
private Telerik.WinControls.UI.RadLabel radLabel3;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
|
||||
private Telerik.WinControls.UI.RadDropDownList radDropDownList_LoginProvider;
|
||||
private Telerik.WinControls.UI.RadButton radButton_ConfigureProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.App.Desktop.LangRes;
|
||||
using OwnChar.Data;
|
||||
using Pilz.Cryptography;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs;
|
||||
|
||||
public partial class TabLoginView : UserControl, ILoadContent
|
||||
{
|
||||
public partial class TabLoginView : UserControl
|
||||
private readonly IMainWindowApi mainApi;
|
||||
private IDataManager? dataManager;
|
||||
|
||||
public TabLoginView(IMainWindowApi mainApi)
|
||||
{
|
||||
public TabLoginView()
|
||||
this.mainApi = mainApi;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void LoadContent()
|
||||
{
|
||||
LoadProvidersList();
|
||||
}
|
||||
|
||||
private void LoadProvidersList()
|
||||
{
|
||||
radDropDownList_LoginProvider.BeginUpdate();
|
||||
|
||||
foreach (var feat in PluginFeatureController.Instance.Features.Get(FeatureCodes.LoginProvider))
|
||||
{
|
||||
InitializeComponent();
|
||||
if (feat is LoginProvider provider)
|
||||
{
|
||||
var item = new RadListDataItem(feat.Name, provider)
|
||||
{
|
||||
SvgImage = feat.Icon as RadSvgImage,
|
||||
Image = feat.Icon as Image,
|
||||
};
|
||||
radDropDownList_LoginProvider.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
radDropDownList_LoginProvider.EndUpdate();
|
||||
|
||||
if (radDropDownList_LoginProvider.Items.Count > 0)
|
||||
radDropDownList_LoginProvider.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void RadDropDownList_LoginProvider_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (radDropDownList_LoginProvider.SelectedValue is LoginProvider provider)
|
||||
dataManager = provider.GetDefault(mainApi);
|
||||
}
|
||||
|
||||
private void RadButton_Login_Click(object sender, EventArgs e)
|
||||
{
|
||||
var username = radTextBoxControl_Username.Text.Trim();
|
||||
var password = (SecureString)radTextBoxControl_Password.Text;
|
||||
|
||||
if (mainApi.Manager?.Login(dataManager, username, password) is not bool success || !success)
|
||||
{
|
||||
RadMessageBox.Show(LoginPageLangRes.MsgBox_LoginFailed, LoginPageLangRes.MsgBox_LoginFailed_Title, MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
mainApi.OpenTab(new TabUserView(mainApi, mainApi.Manager.CurrentUser), mainApi.Manager.CurrentUser!.Username!);
|
||||
mainApi.CloseTab(this);
|
||||
}
|
||||
|
||||
private void RadButton_ConfigureProvider_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (radDropDownList_LoginProvider.SelectedValue is LoginProvider provider)
|
||||
provider.Configure(mainApi, ref dataManager);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user