patbef-ServiceInside/Support/Login.cs

72 lines
1.9 KiB
C#

using Support.Crypto;
using Support.Models;
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 Support
{
public partial class Login : Form
{
private Appsettings Appsettings = null;
private bool _LoginSuccess;
public Login()
{
InitializeComponent();
this.Appsettings = Models.Appsettings.Load();
}
public bool LoginSuccess
{
get
{
return this._LoginSuccess;
}
}
private void btnLogin_Click(object sender, EventArgs e)
{
if(this.Appsettings != null && !string.IsNullOrEmpty(this.Appsettings.SupportPassword))
{
string key = txtPassword.Text;
if(!string.IsNullOrEmpty(key))
{
if(AES.Decrypt(this.Appsettings.SupportPassword, AES.GetKey(key)) == "Support_" + key)
{
this._LoginSuccess = true;
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("Das Support-Passwort ist ungültig");
}
}
else
{
MessageBox.Show("Bitte geben Sie das Support-Passwort ein");
}
}
else
{
MessageBox.Show("Das Support-Passwort ist ungültig");
}
}
private void Login_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
btnLogin_Click(null, null);
}
}
}
}