GUI remote login

This commit is contained in:
Cyberboss
2017-09-14 17:11:52 -04:00
parent 3c99f3a9fd
commit ceae970592
9 changed files with 2468 additions and 16 deletions
+2 -2
View File
@@ -55,7 +55,7 @@ namespace TGCommandLine
if (!Server.Authenticate())
{
Console.WriteLine("Authentication error! Username/password/windows identity is not authorized!");
Console.WriteLine("Authentication error: Username/password/windows identity is not authorized!");
return ExitCode.ConnectionError;
}
@@ -127,7 +127,7 @@ namespace TGCommandLine
}
else if (!Server.Authenticate())
{
Console.WriteLine("Authentication error! Username/password/windows identity is not authorized! Returning to local mode.");
Console.WriteLine("Authentication error: Username/password/windows identity is not authorized! Returning to local mode...");
Server.SetRemoteLoginInformation(null, null, null);
}
else
+6
View File
@@ -26,6 +26,12 @@
<setting name="LastChatProvider" serializeAs="String">
<value>0</value>
</setting>
<setting name="RemoteIP" serializeAs="String">
<value />
</setting>
<setting name="RemoteUsername" serializeAs="String">
<value />
</setting>
</TGControlPanel.Properties.Settings>
<TGControlPanel.Properties.Settings1>
<setting name="LastPageIndex" serializeAs="String">
+187
View File
@@ -0,0 +1,187 @@
namespace TGControlPanel
{
partial class Login
{
/// <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(Login));
this.LocalLoginButton = new System.Windows.Forms.Button();
this.CurrentRevisionTitle = new System.Windows.Forms.Label();
this.IPTextBox = new System.Windows.Forms.TextBox();
this.UsernameTextBox = new System.Windows.Forms.TextBox();
this.PasswordTextBox = new System.Windows.Forms.TextBox();
this.RemoteLoginButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// LocalLoginButton
//
this.LocalLoginButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.LocalLoginButton.Location = new System.Drawing.Point(51, 12);
this.LocalLoginButton.Name = "LocalLoginButton";
this.LocalLoginButton.Size = new System.Drawing.Size(188, 25);
this.LocalLoginButton.TabIndex = 13;
this.LocalLoginButton.Text = "Connect to Local Service";
this.LocalLoginButton.UseVisualStyleBackColor = true;
this.LocalLoginButton.Click += new System.EventHandler(this.LocalLoginButton_Click);
//
// CurrentRevisionTitle
//
this.CurrentRevisionTitle.AutoSize = true;
this.CurrentRevisionTitle.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.CurrentRevisionTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
this.CurrentRevisionTitle.Location = new System.Drawing.Point(81, 76);
this.CurrentRevisionTitle.Name = "CurrentRevisionTitle";
this.CurrentRevisionTitle.Size = new System.Drawing.Size(128, 18);
this.CurrentRevisionTitle.TabIndex = 14;
this.CurrentRevisionTitle.Text = "Remote Login:";
this.CurrentRevisionTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// IPTextBox
//
this.IPTextBox.Location = new System.Drawing.Point(73, 97);
this.IPTextBox.Name = "IPTextBox";
this.IPTextBox.Size = new System.Drawing.Size(199, 20);
this.IPTextBox.TabIndex = 15;
//
// UsernameTextBox
//
this.UsernameTextBox.Location = new System.Drawing.Point(73, 130);
this.UsernameTextBox.Name = "UsernameTextBox";
this.UsernameTextBox.Size = new System.Drawing.Size(199, 20);
this.UsernameTextBox.TabIndex = 16;
//
// PasswordTextBox
//
this.PasswordTextBox.Location = new System.Drawing.Point(73, 162);
this.PasswordTextBox.Name = "PasswordTextBox";
this.PasswordTextBox.Size = new System.Drawing.Size(199, 20);
this.PasswordTextBox.TabIndex = 17;
this.PasswordTextBox.UseSystemPasswordChar = true;
//
// RemoteLoginButton
//
this.RemoteLoginButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.RemoteLoginButton.Location = new System.Drawing.Point(51, 197);
this.RemoteLoginButton.Name = "RemoteLoginButton";
this.RemoteLoginButton.Size = new System.Drawing.Size(188, 25);
this.RemoteLoginButton.TabIndex = 18;
this.RemoteLoginButton.Text = "Connect to Remote Service";
this.RemoteLoginButton.UseVisualStyleBackColor = true;
this.RemoteLoginButton.Click += new System.EventHandler(this.RemoteLoginButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
this.label1.Location = new System.Drawing.Point(9, 99);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 18);
this.label1.TabIndex = 19;
this.label1.Text = "IP:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
this.label2.Location = new System.Drawing.Point(9, 132);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 18);
this.label2.TabIndex = 20;
this.label2.Text = "User:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
this.label3.Location = new System.Drawing.Point(9, 164);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 18);
this.label3.TabIndex = 21;
this.label3.Text = "Pass:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
this.label4.Location = new System.Drawing.Point(-19, 40);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(468, 18);
this.label4.TabIndex = 22;
this.label4.Text = "______________________________________________";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Login
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34)))));
this.ClientSize = new System.Drawing.Size(284, 237);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.RemoteLoginButton);
this.Controls.Add(this.PasswordTextBox);
this.Controls.Add(this.UsernameTextBox);
this.Controls.Add(this.IPTextBox);
this.Controls.Add(this.CurrentRevisionTitle);
this.Controls.Add(this.LocalLoginButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Login";
this.Text = "Login";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button LocalLoginButton;
private System.Windows.Forms.Label CurrentRevisionTitle;
private System.Windows.Forms.TextBox IPTextBox;
private System.Windows.Forms.TextBox UsernameTextBox;
private System.Windows.Forms.TextBox PasswordTextBox;
private System.Windows.Forms.Button RemoteLoginButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
}
}
+51
View File
@@ -0,0 +1,51 @@
using System;
using System.Windows.Forms;
using TGServiceInterface;
namespace TGControlPanel
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
IPTextBox.Text = Properties.Settings.Default.RemoteIP;
UsernameTextBox.Text = Properties.Settings.Default.RemoteUsername;
AcceptButton = RemoteLoginButton;
}
private void RemoteLoginButton_Click(object sender, EventArgs e)
{
IPTextBox.Text = IPTextBox.Text.Trim();
UsernameTextBox.Text = UsernameTextBox.Text.Trim();
Server.SetRemoteLoginInformation(IPTextBox.Text, UsernameTextBox.Text, PasswordTextBox.Text);
Properties.Settings.Default.RemoteIP = IPTextBox.Text;
Properties.Settings.Default.RemoteUsername = UsernameTextBox.Text;
VerifyAndConnect();
}
private void LocalLoginButton_Click(object sender, EventArgs e)
{
Server.SetRemoteLoginInformation(null, null, null);
VerifyAndConnect();
}
void VerifyAndConnect()
{
var res = Server.VerifyConnection();
if (res != null)
{
MessageBox.Show("Unable to connect to service! Error: " + res);
return;
}
if (!Server.Authenticate())
{
MessageBox.Show("Authentication error: Username/password/windows identity is not authorized! Ensure you are a system administrator or in the correct Windows group on the service machine.");
return;
}
Hide();
new Main().ShowDialog();
Close();
}
}
}
File diff suppressed because it is too large Load Diff
+1 -13
View File
@@ -18,21 +18,9 @@ namespace TGControlPanel
Properties.Settings.Default.UpgradeRequired = false;
Properties.Settings.Default.Save();
}
var res = Server.VerifyConnection();
if (res != null)
{
MessageBox.Show("Unable to connect to service! Error: " + res);
return;
}
if (!Server.Authenticate())
{
MessageBox.Show("Authentication error! Username/password/windows identity is not authorized!");
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
return;
Application.Run(new Login());
}
catch (Exception e)
{
+25 -1
View File
@@ -12,7 +12,7 @@ namespace TGControlPanel.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -70,5 +70,29 @@ namespace TGControlPanel.Properties {
this["LastChatProvider"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string RemoteIP {
get {
return ((string)(this["RemoteIP"]));
}
set {
this["RemoteIP"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string RemoteUsername {
get {
return ((string)(this["RemoteUsername"]));
}
set {
this["RemoteUsername"] = value;
}
}
}
}
@@ -14,5 +14,11 @@
<Setting Name="LastChatProvider" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="RemoteIP" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="RemoteUsername" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
+11
View File
@@ -39,10 +39,12 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Windows.Forms.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ByondPage.cs">
@@ -57,6 +59,12 @@
<Compile Include="ConfigPage.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Login.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Login.Designer.cs">
<DependentUpon>Login.cs</DependentUpon>
</Compile>
<Compile Include="Main.cs">
<SubType>Form</SubType>
</Compile>
@@ -77,6 +85,9 @@
<SubType>Form</SubType>
</Compile>
<Compile Include="..\Version.cs" />
<EmbeddedResource Include="Login.resx">
<DependentUpon>Login.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Main.resx">
<DependentUpon>Main.cs</DependentUpon>
</EmbeddedResource>