This commit is contained in:
@@ -85,6 +85,12 @@
|
|||||||
<Compile Include="NameIdItem.cs" />
|
<Compile Include="NameIdItem.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="tfa.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="tfa.Designer.cs">
|
||||||
|
<DependentUpon>tfa.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="util.cs" />
|
<Compile Include="util.cs" />
|
||||||
<EmbeddedResource Include="auth.resx">
|
<EmbeddedResource Include="auth.resx">
|
||||||
<DependentUpon>auth.cs</DependentUpon>
|
<DependentUpon>auth.cs</DependentUpon>
|
||||||
@@ -102,6 +108,9 @@
|
|||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<EmbeddedResource Include="tfa.resx">
|
||||||
|
<DependentUpon>tfa.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
|||||||
@@ -57,8 +57,11 @@ namespace AyaNovaQBI
|
|||||||
{
|
{
|
||||||
MessageBox.Show("Login failed");
|
MessageBox.Show("Login failed");
|
||||||
btnLogin.Enabled = btnTest.Enabled = true;
|
btnLogin.Enabled = btnTest.Enabled = true;
|
||||||
|
this.DialogResult = DialogResult.Cancel;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
btnLogin.Enabled = btnTest.Enabled = true;
|
btnLogin.Enabled = btnTest.Enabled = true;
|
||||||
|
|
||||||
this.DialogResult = DialogResult.OK;
|
this.DialogResult = DialogResult.OK;
|
||||||
|
|||||||
105
AyaNovaQBI/tfa.Designer.cs
generated
Normal file
105
AyaNovaQBI/tfa.Designer.cs
generated
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
namespace AyaNovaQBI
|
||||||
|
{
|
||||||
|
partial class tfa
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(tfa));
|
||||||
|
this.edTFACode = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnVerifyCode = new System.Windows.Forms.Button();
|
||||||
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// edTFACode
|
||||||
|
//
|
||||||
|
this.edTFACode.Location = new System.Drawing.Point(15, 66);
|
||||||
|
this.edTFACode.Name = "edTFACode";
|
||||||
|
this.edTFACode.Size = new System.Drawing.Size(284, 20);
|
||||||
|
this.edTFACode.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// btnVerifyCode
|
||||||
|
//
|
||||||
|
this.btnVerifyCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btnVerifyCode.Location = new System.Drawing.Point(224, 126);
|
||||||
|
this.btnVerifyCode.Name = "btnVerifyCode";
|
||||||
|
this.btnVerifyCode.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnVerifyCode.TabIndex = 9;
|
||||||
|
this.btnVerifyCode.Text = "Verify code";
|
||||||
|
this.btnVerifyCode.UseVisualStyleBackColor = true;
|
||||||
|
this.btnVerifyCode.Click += new System.EventHandler(this.btnVerifyCode_click);
|
||||||
|
//
|
||||||
|
// btnCancel
|
||||||
|
//
|
||||||
|
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.btnCancel.Location = new System.Drawing.Point(12, 126);
|
||||||
|
this.btnCancel.Name = "btnCancel";
|
||||||
|
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnCancel.TabIndex = 10;
|
||||||
|
this.btnCancel.Text = "Cancel";
|
||||||
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(12, 36);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(93, 13);
|
||||||
|
this.label1.TabIndex = 11;
|
||||||
|
this.label1.Text = "Enter 6 digit code";
|
||||||
|
//
|
||||||
|
// tfa
|
||||||
|
//
|
||||||
|
this.AcceptButton = this.btnVerifyCode;
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.AutoSize = true;
|
||||||
|
this.CancelButton = this.btnCancel;
|
||||||
|
this.ClientSize = new System.Drawing.Size(318, 179);
|
||||||
|
this.ControlBox = false;
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.btnCancel);
|
||||||
|
this.Controls.Add(this.btnVerifyCode);
|
||||||
|
this.Controls.Add(this.edTFACode);
|
||||||
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.Name = "tfa";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Two-Factor Authentication";
|
||||||
|
this.Load += new System.EventHandler(this.auth_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private System.Windows.Forms.TextBox edTFACode;
|
||||||
|
private System.Windows.Forms.Button btnVerifyCode;
|
||||||
|
private System.Windows.Forms.Button btnCancel;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
}
|
||||||
|
}
|
||||||
46
AyaNovaQBI/tfa.cs
Normal file
46
AyaNovaQBI/tfa.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace AyaNovaQBI
|
||||||
|
{
|
||||||
|
public partial class tfa : Form
|
||||||
|
{
|
||||||
|
public string TFACode { get; set; }
|
||||||
|
public tfa()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void auth_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async void btnVerifyCode_click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
var res = await util.AuthenticateTFAAsync(ed);
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Login failed");
|
||||||
|
btnLogin.Enabled = btnTest.Enabled = true;
|
||||||
|
this.DialogResult = DialogResult.Cancel;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
4051
AyaNovaQBI/tfa.resx
Normal file
4051
AyaNovaQBI/tfa.resx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -100,7 +100,20 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var a= new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(await response.Content.ReadAsStringAsync()) };
|
var a= new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(await response.Content.ReadAsStringAsync()) };
|
||||||
|
bool tfa = a.ObjectResponse["data"]["tfa"].Value<bool>();
|
||||||
|
if (tfa == true)
|
||||||
|
{
|
||||||
|
//get 2fa code and send it in
|
||||||
|
tfa t = new tfa();
|
||||||
|
if(t.ShowDialog()==System.Windows.Forms.DialogResult.Cancel) return false;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
JWT = a.ObjectResponse["data"]["token"].Value<string>();
|
JWT = a.ObjectResponse["data"]["token"].Value<string>();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user