Libation 4.0 prep: do not allow user to change login id in the middle of logging in. If they do then jsonpath will fail

This commit is contained in:
Robert McRackan 2020-08-28 15:03:55 -04:00
parent d24c10ddf5
commit a58f51a8ce
4 changed files with 62 additions and 47 deletions

View File

@ -29,10 +29,10 @@
private void InitializeComponent()
{
this.passwordLbl = new System.Windows.Forms.Label();
this.emailLbl = new System.Windows.Forms.Label();
this.passwordTb = new System.Windows.Forms.TextBox();
this.emailTb = new System.Windows.Forms.TextBox();
this.submitBtn = new System.Windows.Forms.Button();
this.localeLbl = new System.Windows.Forms.Label();
this.usernameLbl = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// passwordLbl
@ -44,15 +44,6 @@
this.passwordLbl.TabIndex = 2;
this.passwordLbl.Text = "Password";
//
// emailLbl
//
this.emailLbl.AutoSize = true;
this.emailLbl.Location = new System.Drawing.Point(12, 15);
this.emailLbl.Name = "emailLbl";
this.emailLbl.Size = new System.Drawing.Size(32, 13);
this.emailLbl.TabIndex = 0;
this.emailLbl.Text = "Email";
//
// passwordTb
//
this.passwordTb.Location = new System.Drawing.Point(71, 38);
@ -61,13 +52,6 @@
this.passwordTb.Size = new System.Drawing.Size(200, 20);
this.passwordTb.TabIndex = 3;
//
// emailTb
//
this.emailTb.Location = new System.Drawing.Point(71, 12);
this.emailTb.Name = "emailTb";
this.emailTb.Size = new System.Drawing.Size(200, 20);
this.emailTb.TabIndex = 1;
//
// submitBtn
//
this.submitBtn.Location = new System.Drawing.Point(196, 64);
@ -78,17 +62,35 @@
this.submitBtn.UseVisualStyleBackColor = true;
this.submitBtn.Click += new System.EventHandler(this.submitBtn_Click);
//
// localeLbl
//
this.localeLbl.AutoSize = true;
this.localeLbl.Location = new System.Drawing.Point(12, 9);
this.localeLbl.Name = "localeLbl";
this.localeLbl.Size = new System.Drawing.Size(59, 13);
this.localeLbl.TabIndex = 0;
this.localeLbl.Text = "Locale: {0}";
//
// usernameLbl
//
this.usernameLbl.AutoSize = true;
this.usernameLbl.Location = new System.Drawing.Point(12, 22);
this.usernameLbl.Name = "usernameLbl";
this.usernameLbl.Size = new System.Drawing.Size(75, 13);
this.usernameLbl.TabIndex = 1;
this.usernameLbl.Text = "Username: {0}";
//
// AudibleLoginDialog
//
this.AcceptButton = this.submitBtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(283, 99);
this.Controls.Add(this.usernameLbl);
this.Controls.Add(this.localeLbl);
this.Controls.Add(this.submitBtn);
this.Controls.Add(this.passwordLbl);
this.Controls.Add(this.emailLbl);
this.Controls.Add(this.passwordTb);
this.Controls.Add(this.emailTb);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
@ -104,9 +106,9 @@
#endregion
private System.Windows.Forms.Label passwordLbl;
private System.Windows.Forms.Label emailLbl;
private System.Windows.Forms.TextBox passwordTb;
private System.Windows.Forms.TextBox emailTb;
private System.Windows.Forms.Button submitBtn;
private System.Windows.Forms.Label localeLbl;
private System.Windows.Forms.Label usernameLbl;
}
}

View File

@ -1,21 +1,32 @@
using System;
using System.Windows.Forms;
using InternalUtilities;
namespace LibationWinForms.Dialogs.Login
{
public partial class AudibleLoginDialog : Form
{
private string locale { get; }
private string accountId { get; }
public string Email { get; private set; }
public string Password { get; private set; }
public AudibleLoginDialog()
public AudibleLoginDialog(Account account)
{
InitializeComponent();
locale = account.Locale.Name;
accountId = account.AccountId;
// do not allow user to change login id here. if they do then jsonpath will fail
this.localeLbl.Text = string.Format(this.localeLbl.Text, locale);
this.usernameLbl.Text = string.Format(this.usernameLbl.Text, accountId);
}
private void submitBtn_Click(object sender, EventArgs e)
{
Email = this.emailTb.Text;
Email = accountId;
Password = this.passwordTb.Text;
DialogResult = DialogResult.OK;

View File

@ -32,7 +32,7 @@ namespace LibationWinForms.Login
public (string email, string password) GetLogin()
{
using var dialog = new AudibleLoginDialog();
using var dialog = new AudibleLoginDialog(_account);
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
return (dialog.Email, dialog.Password);
return (null, null);

View File

@ -29,10 +29,10 @@
private void InitializeComponent()
{
this.passwordLbl = new System.Windows.Forms.Label();
this.emailLbl = new System.Windows.Forms.Label();
this.passwordTb = new System.Windows.Forms.TextBox();
this.emailTb = new System.Windows.Forms.TextBox();
this.submitBtn = new System.Windows.Forms.Button();
this.localeLbl = new System.Windows.Forms.Label();
this.usernameLbl = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// passwordLbl
@ -44,15 +44,6 @@
this.passwordLbl.TabIndex = 2;
this.passwordLbl.Text = "Password";
//
// emailLbl
//
this.emailLbl.AutoSize = true;
this.emailLbl.Location = new System.Drawing.Point(12, 15);
this.emailLbl.Name = "emailLbl";
this.emailLbl.Size = new System.Drawing.Size(32, 13);
this.emailLbl.TabIndex = 0;
this.emailLbl.Text = "Email";
//
// passwordTb
//
this.passwordTb.Location = new System.Drawing.Point(71, 38);
@ -61,13 +52,6 @@
this.passwordTb.Size = new System.Drawing.Size(200, 20);
this.passwordTb.TabIndex = 3;
//
// emailTb
//
this.emailTb.Location = new System.Drawing.Point(71, 12);
this.emailTb.Name = "emailTb";
this.emailTb.Size = new System.Drawing.Size(200, 20);
this.emailTb.TabIndex = 1;
//
// submitBtn
//
this.submitBtn.Location = new System.Drawing.Point(196, 64);
@ -77,17 +61,35 @@
this.submitBtn.Text = "Submit";
this.submitBtn.UseVisualStyleBackColor = true;
//
// localeLbl
//
this.localeLbl.AutoSize = true;
this.localeLbl.Location = new System.Drawing.Point(12, 9);
this.localeLbl.Name = "localeLbl";
this.localeLbl.Size = new System.Drawing.Size(59, 13);
this.localeLbl.TabIndex = 0;
this.localeLbl.Text = "Locale: {0}";
//
// usernameLbl
//
this.usernameLbl.AutoSize = true;
this.usernameLbl.Location = new System.Drawing.Point(12, 22);
this.usernameLbl.Name = "usernameLbl";
this.usernameLbl.Size = new System.Drawing.Size(75, 13);
this.usernameLbl.TabIndex = 1;
this.usernameLbl.Text = "Username: {0}";
//
// AudibleLoginDialog
//
this.AcceptButton = this.submitBtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(283, 99);
this.Controls.Add(this.usernameLbl);
this.Controls.Add(this.localeLbl);
this.Controls.Add(this.submitBtn);
this.Controls.Add(this.passwordLbl);
this.Controls.Add(this.emailLbl);
this.Controls.Add(this.passwordTb);
this.Controls.Add(this.emailTb);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
@ -103,9 +105,9 @@
#endregion
private System.Windows.Forms.Label passwordLbl;
private System.Windows.Forms.Label emailLbl;
private System.Windows.Forms.TextBox passwordTb;
private System.Windows.Forms.TextBox emailTb;
private System.Windows.Forms.Button submitBtn;
private System.Windows.Forms.Label localeLbl;
private System.Windows.Forms.Label usernameLbl;
}
}