Binary file not shown.
Binary file not shown.
@@ -6,3 +6,4 @@ C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard Socket\obj\Debug
|
|||||||
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard Socket\obj\Debug\netcoreapp3.1\Server Dashboard Socket.csproj.CoreCompileInputs.cache
|
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard Socket\obj\Debug\netcoreapp3.1\Server Dashboard Socket.csproj.CoreCompileInputs.cache
|
||||||
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard Socket\obj\Debug\netcoreapp3.1\Server Dashboard Socket.dll
|
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard Socket\obj\Debug\netcoreapp3.1\Server Dashboard Socket.dll
|
||||||
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard Socket\obj\Debug\netcoreapp3.1\Server Dashboard Socket.pdb
|
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard Socket\obj\Debug\netcoreapp3.1\Server Dashboard Socket.pdb
|
||||||
|
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard Socket\obj\Debug\netcoreapp3.1\Server Dashboard Socket.csprojAssemblyReference.cache
|
||||||
|
|||||||
Binary file not shown.
@@ -35,40 +35,49 @@ namespace Server_Dashboard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CheckCookie(string cookie, string username) {
|
public static int CheckCookie(string cookie, string username) {
|
||||||
string valid = "False";
|
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString)) {
|
||||||
ConnectToDatabase(con => {
|
try {
|
||||||
|
con.Open();
|
||||||
string query = "EXEC CheckUserCookie @Cookie = @cookie, @UserName = @username, @Valid = @valid OUTPUT";
|
string query = "EXEC CheckUserCookie @Cookie = @cookie, @UserName = @username, @Valid = @valid OUTPUT";
|
||||||
using (SqlCommand com = new SqlCommand(query, con)) {
|
using (SqlCommand com = new SqlCommand(query, con)) {
|
||||||
com.Parameters.AddWithValue("@cookie", cookie);
|
com.Parameters.AddWithValue("@cookie", cookie);
|
||||||
com.Parameters.AddWithValue("@username", username);
|
com.Parameters.AddWithValue("@username", username);
|
||||||
com.Parameters.Add("@valid", SqlDbType.NVarChar, 250);
|
com.Parameters.Add("@valid", SqlDbType.Bit);
|
||||||
com.Parameters["@valid"].Direction = ParameterDirection.Output;
|
com.Parameters["@valid"].Direction = ParameterDirection.Output;
|
||||||
com.ExecuteNonQuery();
|
com.ExecuteNonQuery();
|
||||||
valid = Convert.ToString(com.Parameters["@Valid"].Value);
|
return Convert.ToInt32(com.Parameters["@Valid"].Value);
|
||||||
|
}
|
||||||
|
} catch (SqlException ex) {
|
||||||
|
return ex.Number;
|
||||||
|
} finally {
|
||||||
|
con.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return Convert.ToBoolean(valid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool DeleteCookie(string username) {
|
public static void DeleteCookie(string username) {
|
||||||
string valid = "False";
|
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString)) {
|
||||||
ConnectToDatabase(con => {
|
try {
|
||||||
|
con.Open();
|
||||||
string query = "EXEC DeleteUserCookie @Username = @username, @ResponseMessage = @response OUTPUT";
|
string query = "EXEC DeleteUserCookie @Username = @username, @ResponseMessage = @response OUTPUT";
|
||||||
using (SqlCommand com = new SqlCommand(query, con)) {
|
using (SqlCommand com = new SqlCommand(query, con)) {
|
||||||
com.Parameters.AddWithValue("@username", username);
|
com.Parameters.AddWithValue("@username", username);
|
||||||
com.Parameters.Add("@response", SqlDbType.NVarChar, 250);
|
com.Parameters.Add("@response", SqlDbType.NVarChar, 250);
|
||||||
com.Parameters["@response"].Direction = ParameterDirection.Output;
|
com.Parameters["@response"].Direction = ParameterDirection.Output;
|
||||||
com.ExecuteNonQuery();
|
com.ExecuteNonQuery();
|
||||||
valid = Convert.ToString(com.Parameters["@ResponseMessage"].Value);
|
|
||||||
}
|
}
|
||||||
});
|
} catch (SqlException ex) {
|
||||||
return Convert.ToBoolean(valid);
|
} finally {
|
||||||
|
con.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AddCookie(string cookie, string username) {
|
public static int AddCookie(string cookie, string username) {
|
||||||
string valid = "False";
|
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString)) {
|
||||||
ConnectToDatabase(con => {
|
try {
|
||||||
|
con.Open();
|
||||||
string query = "EXEC AddCookieToUser @Cookie = @cookie, @UserName = @username, @ResponseMessage = @response OUTPUT";
|
string query = "EXEC AddCookieToUser @Cookie = @cookie, @UserName = @username, @ResponseMessage = @response OUTPUT";
|
||||||
using (SqlCommand com = new SqlCommand(query, con)) {
|
using (SqlCommand com = new SqlCommand(query, con)) {
|
||||||
com.Parameters.AddWithValue("@cookie", cookie);
|
com.Parameters.AddWithValue("@cookie", cookie);
|
||||||
@@ -76,30 +85,14 @@ namespace Server_Dashboard {
|
|||||||
com.Parameters.Add("@response", SqlDbType.NVarChar, 250);
|
com.Parameters.Add("@response", SqlDbType.NVarChar, 250);
|
||||||
com.Parameters["@response"].Direction = ParameterDirection.Output;
|
com.Parameters["@response"].Direction = ParameterDirection.Output;
|
||||||
com.ExecuteNonQuery();
|
com.ExecuteNonQuery();
|
||||||
valid = Convert.ToString(com.Parameters["@ResponseMessage"].Value);
|
return Convert.ToInt32(com.Parameters["@ResponseMessage"].Value);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return Convert.ToBoolean(valid);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Private methods
|
|
||||||
/// <summary>
|
|
||||||
/// Opens a database connection
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="callback">Callback type SqlConnection</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static SqlConnection ConnectToDatabase(Action<SqlConnection> callback) {
|
|
||||||
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString)) {
|
|
||||||
try {
|
|
||||||
con.Open();
|
|
||||||
callback(con);
|
|
||||||
con.Close();
|
|
||||||
} catch (SqlException ex) {
|
} catch (SqlException ex) {
|
||||||
return null;
|
return ex.Number;
|
||||||
|
} finally {
|
||||||
|
con.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
Server Dashboard/Properties/Settings.Designer.cs
generated
12
Server Dashboard/Properties/Settings.Designer.cs
generated
@@ -58,5 +58,17 @@ namespace Server_Dashboard.Properties {
|
|||||||
this["RememberMe"] = value;
|
this["RememberMe"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
|
public string Password {
|
||||||
|
get {
|
||||||
|
return ((string)(this["Password"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["Password"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,8 @@
|
|||||||
<Setting Name="RememberMe" Type="System.Boolean" Scope="User">
|
<Setting Name="RememberMe" Type="System.Boolean" Scope="User">
|
||||||
<Value Profile="(Default)">False</Value>
|
<Value Profile="(Default)">False</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="Password" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
@@ -60,6 +60,7 @@ namespace Server_Dashboard {
|
|||||||
Username = Settings.Default.Username;
|
Username = Settings.Default.Username;
|
||||||
RememberUser = Settings.Default.RememberMe;
|
RememberUser = Settings.Default.RememberMe;
|
||||||
}
|
}
|
||||||
|
AutoLoginAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand LoginCommand { get; set; }
|
public ICommand LoginCommand { get; set; }
|
||||||
@@ -81,6 +82,7 @@ namespace Server_Dashboard {
|
|||||||
Settings.Default.Cookies = null;
|
Settings.Default.Cookies = null;
|
||||||
Settings.Default.Username = "";
|
Settings.Default.Username = "";
|
||||||
Settings.Default.RememberMe = false;
|
Settings.Default.RememberMe = false;
|
||||||
|
Settings.Default.Password = "";
|
||||||
Settings.Default.Save();
|
Settings.Default.Save();
|
||||||
DatabaseHandler.DeleteCookie(Username);
|
DatabaseHandler.DeleteCookie(Username);
|
||||||
}
|
}
|
||||||
@@ -89,6 +91,7 @@ namespace Server_Dashboard {
|
|||||||
Settings.Default.Cookies = guid;
|
Settings.Default.Cookies = guid;
|
||||||
Settings.Default.Username = Username;
|
Settings.Default.Username = Username;
|
||||||
Settings.Default.RememberMe = true;
|
Settings.Default.RememberMe = true;
|
||||||
|
Settings.Default.Password = "*****";
|
||||||
Settings.Default.Save();
|
Settings.Default.Save();
|
||||||
DatabaseHandler.AddCookie(Username, guid);
|
DatabaseHandler.AddCookie(Username, guid);
|
||||||
}
|
}
|
||||||
@@ -117,5 +120,19 @@ namespace Server_Dashboard {
|
|||||||
}
|
}
|
||||||
ErrorText = "";
|
ErrorText = "";
|
||||||
}
|
}
|
||||||
|
//TODO: Add autologin function that locks the UI untill the user hits the abort button or the login completes
|
||||||
|
/*private async void AutoLoginAsync() {
|
||||||
|
if (Settings.Default.RememberMe && !String.IsNullOrEmpty(Settings.Default.Username) && !String.IsNullOrEmpty(Settings.Default.Cookies)) {
|
||||||
|
Loading = "Visible";
|
||||||
|
int result = await Task.Run(() => DatabaseHandler.CheckCookie(Settings.Default.Cookies, Username));
|
||||||
|
Loading = "Hidden";
|
||||||
|
if (result == 1) {
|
||||||
|
DashboardWindow window = new DashboardWindow();
|
||||||
|
window.Show();
|
||||||
|
Close?.Invoke();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,11 @@
|
|||||||
|
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\obj\Debug\netcoreapp3.1\GeneratedInternalTypeHelper.g.i.cs
|
||||||
|
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\App.xaml;;
|
||||||
|
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\Dashboard\CRUD Popup\CreateModulePopup.xaml;;
|
||||||
|
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\DoubleRoundProgressBar\DoubleRoundProgressBar.xaml;;
|
||||||
|
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\HalfRoundProgressBar\HalfRoundProgressBar.xaml;;
|
||||||
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\LoadingIndicator\LoadingIndicator.xaml;;
|
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\LoadingIndicator\LoadingIndicator.xaml;;
|
||||||
|
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\ServerModules\ServerModule.xaml;;
|
||||||
|
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\LoginWindow.xaml;;
|
||||||
|
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Views\DashboardPages\MainDashboardPage.xaml;;
|
||||||
|
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Views\DashboardWindow.xaml;;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user