diff --git a/.vs/Server Dashboard/DesignTimeBuild/.dtbcache.v2 b/.vs/Server Dashboard/DesignTimeBuild/.dtbcache.v2 index 2f16743..272ce64 100644 Binary files a/.vs/Server Dashboard/DesignTimeBuild/.dtbcache.v2 and b/.vs/Server Dashboard/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/Server Dashboard/v16/.suo b/.vs/Server Dashboard/v16/.suo index 7ebdc78..e6b8a61 100644 Binary files a/.vs/Server Dashboard/v16/.suo and b/.vs/Server Dashboard/v16/.suo differ diff --git a/Server Dashboard Socket/obj/Debug/netcoreapp3.1/Server Dashboard Socket.csproj.FileListAbsolute.txt b/Server Dashboard Socket/obj/Debug/netcoreapp3.1/Server Dashboard Socket.csproj.FileListAbsolute.txt index 29ff18e..762495d 100644 --- a/Server Dashboard Socket/obj/Debug/netcoreapp3.1/Server Dashboard Socket.csproj.FileListAbsolute.txt +++ b/Server Dashboard Socket/obj/Debug/netcoreapp3.1/Server Dashboard Socket.csproj.FileListAbsolute.txt @@ -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.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.csprojAssemblyReference.cache diff --git a/Server Dashboard Socket/obj/Debug/netcoreapp3.1/Server Dashboard Socket.csprojAssemblyReference.cache b/Server Dashboard Socket/obj/Debug/netcoreapp3.1/Server Dashboard Socket.csprojAssemblyReference.cache new file mode 100644 index 0000000..8a5ef04 Binary files /dev/null and b/Server Dashboard Socket/obj/Debug/netcoreapp3.1/Server Dashboard Socket.csprojAssemblyReference.cache differ diff --git a/Server Dashboard/Database/DatabaseHandler.cs b/Server Dashboard/Database/DatabaseHandler.cs index 16d3c05..5fce34a 100644 --- a/Server Dashboard/Database/DatabaseHandler.cs +++ b/Server Dashboard/Database/DatabaseHandler.cs @@ -35,71 +35,64 @@ namespace Server_Dashboard { } } - public static bool CheckCookie(string cookie, string username) { - string valid = "False"; - ConnectToDatabase(con => { - string query = "EXEC CheckUserCookie @Cookie = @cookie, @UserName = @username, @Valid = @valid OUTPUT"; - using (SqlCommand com = new SqlCommand(query, con)) { - com.Parameters.AddWithValue("@cookie", cookie); - com.Parameters.AddWithValue("@username", username); - com.Parameters.Add("@valid", SqlDbType.NVarChar, 250); - com.Parameters["@valid"].Direction = ParameterDirection.Output; - com.ExecuteNonQuery(); - valid = Convert.ToString(com.Parameters["@Valid"].Value); - } - }); - return Convert.ToBoolean(valid); - } - - public static bool DeleteCookie(string username) { - string valid = "False"; - ConnectToDatabase(con => { - string query = "EXEC DeleteUserCookie @Username = @username, @ResponseMessage = @response OUTPUT"; - using (SqlCommand com = new SqlCommand(query, con)) { - com.Parameters.AddWithValue("@username", username); - com.Parameters.Add("@response", SqlDbType.NVarChar, 250); - com.Parameters["@response"].Direction = ParameterDirection.Output; - com.ExecuteNonQuery(); - valid = Convert.ToString(com.Parameters["@ResponseMessage"].Value); - } - }); - return Convert.ToBoolean(valid); - } - - public static bool AddCookie(string cookie, string username) { - string valid = "False"; - ConnectToDatabase(con => { - string query = "EXEC AddCookieToUser @Cookie = @cookie, @UserName = @username, @ResponseMessage = @response OUTPUT"; - using (SqlCommand com = new SqlCommand(query, con)) { - com.Parameters.AddWithValue("@cookie", cookie); - com.Parameters.AddWithValue("@username", username); - com.Parameters.Add("@response", SqlDbType.NVarChar, 250); - com.Parameters["@response"].Direction = ParameterDirection.Output; - com.ExecuteNonQuery(); - valid = Convert.ToString(com.Parameters["@ResponseMessage"].Value); - } - }); - return Convert.ToBoolean(valid); - } - - #region Private methods - /// - /// Opens a database connection - /// - /// Callback type SqlConnection - /// - private static SqlConnection ConnectToDatabase(Action callback) { + public static int CheckCookie(string cookie, string username) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString)) { try { con.Open(); - callback(con); - con.Close(); + string query = "EXEC CheckUserCookie @Cookie = @cookie, @UserName = @username, @Valid = @valid OUTPUT"; + using (SqlCommand com = new SqlCommand(query, con)) { + com.Parameters.AddWithValue("@cookie", cookie); + com.Parameters.AddWithValue("@username", username); + com.Parameters.Add("@valid", SqlDbType.Bit); + com.Parameters["@valid"].Direction = ParameterDirection.Output; + com.ExecuteNonQuery(); + return Convert.ToInt32(com.Parameters["@Valid"].Value); + } } catch (SqlException ex) { - return null; + return ex.Number; + } finally { + con.Close(); + } + } + } + + public static void DeleteCookie(string username) { + using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString)) { + try { + con.Open(); + string query = "EXEC DeleteUserCookie @Username = @username, @ResponseMessage = @response OUTPUT"; + using (SqlCommand com = new SqlCommand(query, con)) { + com.Parameters.AddWithValue("@username", username); + com.Parameters.Add("@response", SqlDbType.NVarChar, 250); + com.Parameters["@response"].Direction = ParameterDirection.Output; + com.ExecuteNonQuery(); + } + } catch (SqlException ex) { + } finally { + con.Close(); + } + } + } + + public static int AddCookie(string cookie, string username) { + using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString)) { + try { + con.Open(); + string query = "EXEC AddCookieToUser @Cookie = @cookie, @UserName = @username, @ResponseMessage = @response OUTPUT"; + using (SqlCommand com = new SqlCommand(query, con)) { + com.Parameters.AddWithValue("@cookie", cookie); + com.Parameters.AddWithValue("@username", username); + com.Parameters.Add("@response", SqlDbType.NVarChar, 250); + com.Parameters["@response"].Direction = ParameterDirection.Output; + com.ExecuteNonQuery(); + return Convert.ToInt32(com.Parameters["@ResponseMessage"].Value); + } + } catch (SqlException ex) { + return ex.Number; + } finally { + con.Close(); } } - return null; } - #endregion } } diff --git a/Server Dashboard/Properties/Settings.Designer.cs b/Server Dashboard/Properties/Settings.Designer.cs index 01abcab..4817d7f 100644 --- a/Server Dashboard/Properties/Settings.Designer.cs +++ b/Server Dashboard/Properties/Settings.Designer.cs @@ -58,5 +58,17 @@ namespace Server_Dashboard.Properties { 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; + } + } } } diff --git a/Server Dashboard/Properties/Settings.settings b/Server Dashboard/Properties/Settings.settings index de72377..3f42ea4 100644 --- a/Server Dashboard/Properties/Settings.settings +++ b/Server Dashboard/Properties/Settings.settings @@ -11,5 +11,8 @@ False + + + \ No newline at end of file diff --git a/Server Dashboard/ViewModels/Login/LoginViewModel.cs b/Server Dashboard/ViewModels/Login/LoginViewModel.cs index be00f9b..a2d8b49 100644 --- a/Server Dashboard/ViewModels/Login/LoginViewModel.cs +++ b/Server Dashboard/ViewModels/Login/LoginViewModel.cs @@ -66,8 +66,12 @@ namespace Server_Dashboard { private async void LoginAsync(object parameter) { if (!String.IsNullOrWhiteSpace(Username) && !String.IsNullOrWhiteSpace((parameter as IHavePassword).SecurePassword.Unsecure())) { + int result = 0; + if (RememberUser && !String.IsNullOrEmpty(Settings.Default.Username) && !String.IsNullOrEmpty(Settings.Default.Cookies) && Settings.Default.Password.Length == 6) { + result = await Task.Run(() => DatabaseHandler.CheckCookie(Settings.Default.Cookies, Username)); + } Loading = "Visible"; - int result = await Task.Run(() => DatabaseHandler.CheckLogin(Username, (parameter as IHavePassword).SecurePassword.Unsecure())); + result = await Task.Run(() => DatabaseHandler.CheckLogin(Username, (parameter as IHavePassword).SecurePassword.Unsecure())); Loading = "Hidden"; switch (result) { case 0: @@ -81,6 +85,7 @@ namespace Server_Dashboard { Settings.Default.Cookies = null; Settings.Default.Username = ""; Settings.Default.RememberMe = false; + Settings.Default.Password = ""; Settings.Default.Save(); DatabaseHandler.DeleteCookie(Username); } @@ -89,6 +94,7 @@ namespace Server_Dashboard { Settings.Default.Cookies = guid; Settings.Default.Username = Username; Settings.Default.RememberMe = true; + Settings.Default.Password = "*****"; Settings.Default.Save(); DatabaseHandler.AddCookie(Username, guid); } diff --git a/Server Dashboard/bin/Debug/netcoreapp3.1/Server Dashboard.dll b/Server Dashboard/bin/Debug/netcoreapp3.1/Server Dashboard.dll index a20d72d..9988d79 100644 Binary files a/Server Dashboard/bin/Debug/netcoreapp3.1/Server Dashboard.dll and b/Server Dashboard/bin/Debug/netcoreapp3.1/Server Dashboard.dll differ diff --git a/Server Dashboard/bin/Debug/netcoreapp3.1/Server Dashboard.pdb b/Server Dashboard/bin/Debug/netcoreapp3.1/Server Dashboard.pdb index 34e65dd..7a6506c 100644 Binary files a/Server Dashboard/bin/Debug/netcoreapp3.1/Server Dashboard.pdb and b/Server Dashboard/bin/Debug/netcoreapp3.1/Server Dashboard.pdb differ diff --git a/Server Dashboard/obj/Debug/netcoreapp3.1/LoginWindow.g.i.cs b/Server Dashboard/obj/Debug/netcoreapp3.1/LoginWindow.g.i.cs index 6294198..a87f9b3 100644 --- a/Server Dashboard/obj/Debug/netcoreapp3.1/LoginWindow.g.i.cs +++ b/Server Dashboard/obj/Debug/netcoreapp3.1/LoginWindow.g.i.cs @@ -1,4 +1,5 @@ -#pragma checksum "..\..\..\LoginWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "BC333A5F7B9E8D68E824FFFBFE4539E4AA85365F" +// Updated by XamlIntelliSenseFileGenerator 05.08.2021 22:10:48 +#pragma checksum "..\..\..\LoginWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "BC333A5F7B9E8D68E824FFFBFE4539E4AA85365F" //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -40,47 +41,42 @@ using System.Windows.Shell; namespace Server_Dashboard { - - + + /// /// LoginWindow /// public partial class LoginWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector { - - - #line 9 "..\..\..\LoginWindow.xaml" - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] - internal Server_Dashboard.LoginWindow Login; - - #line default - #line hidden - - - #line 130 "..\..\..\LoginWindow.xaml" + +#line default +#line hidden + + +#line 130 "..\..\..\LoginWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox UserName; - - #line default - #line hidden - - - #line 174 "..\..\..\LoginWindow.xaml" + +#line default +#line hidden + + +#line 174 "..\..\..\LoginWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.PasswordBox Password; - - #line default - #line hidden - - - #line 185 "..\..\..\LoginWindow.xaml" + +#line default +#line hidden + + +#line 185 "..\..\..\LoginWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBlock PasswordHint; - - #line default - #line hidden - + +#line default +#line hidden + private bool _contentLoaded; - + /// /// InitializeComponent /// @@ -92,21 +88,21 @@ namespace Server_Dashboard { } _contentLoaded = true; System.Uri resourceLocater = new System.Uri("/Server Dashboard;component/loginwindow.xaml", System.UriKind.Relative); - - #line 1 "..\..\..\LoginWindow.xaml" + +#line 1 "..\..\..\LoginWindow.xaml" System.Windows.Application.LoadComponent(this, resourceLocater); - - #line default - #line hidden + +#line default +#line hidden } - + [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "5.0.4.0")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal System.Delegate _CreateDelegate(System.Type delegateType, string handler) { return System.Delegate.CreateDelegate(delegateType, this, handler); } - + [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "5.0.4.0")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -114,23 +110,24 @@ namespace Server_Dashboard { [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { - switch (connectionId) - { - case 1: - this.Login = ((Server_Dashboard.LoginWindow)(target)); - return; - case 2: - this.UserName = ((System.Windows.Controls.TextBox)(target)); - return; - case 3: - this.Password = ((System.Windows.Controls.PasswordBox)(target)); - return; - case 4: - this.PasswordHint = ((System.Windows.Controls.TextBlock)(target)); - return; + switch (connectionId) { + case 1: + this.Login = ((Server_Dashboard.LoginWindow)(target)); + return; + case 2: + this.UserName = ((System.Windows.Controls.TextBox)(target)); + return; + case 3: + this.Password = ((System.Windows.Controls.PasswordBox)(target)); + return; + case 4: + this.PasswordHint = ((System.Windows.Controls.TextBlock)(target)); + return; } this._contentLoaded = true; } + + internal System.Windows.Window Login; } } diff --git a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.csprojAssemblyReference.cache b/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.csprojAssemblyReference.cache index 783e1fd..e607ae1 100644 Binary files a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.csprojAssemblyReference.cache and b/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.csprojAssemblyReference.cache differ diff --git a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.dll b/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.dll index a20d72d..9988d79 100644 Binary files a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.dll and b/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.dll differ diff --git a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.pdb b/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.pdb index 34e65dd..7a6506c 100644 Binary files a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.pdb and b/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard.pdb differ diff --git a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard_MarkupCompile.i.cache b/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard_MarkupCompile.i.cache index 465d905..cf7027a 100644 --- a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard_MarkupCompile.i.cache +++ b/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard_MarkupCompile.i.cache @@ -16,5 +16,5 @@ C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\App.xaml 2061472260849 Controls\Dashboard\CRUD Popup\CreateModulePopup.xaml;Controls\DoubleRoundProgressBar\DoubleRoundProgressBar.xaml;Controls\HalfRoundProgressBar\HalfRoundProgressBar.xaml;Controls\LoadingIndicator\LoadingIndicator.xaml;Controls\ServerModules\ServerModule.xaml;LoginWindow.xaml;Views\DashboardPages\MainDashboardPage.xaml;Views\DashboardWindow.xaml; -True +False diff --git a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard_MarkupCompile.i.lref b/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard_MarkupCompile.i.lref deleted file mode 100644 index 04dfb39..0000000 --- a/Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard_MarkupCompile.i.lref +++ /dev/null @@ -1,4 +0,0 @@ - - -FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\LoadingIndicator\LoadingIndicator.xaml;; -