diff --git a/Account.cs b/Account.cs index 0d2e175..15674d6 100644 --- a/Account.cs +++ b/Account.cs @@ -170,6 +170,21 @@ namespace NightmareCoreWeb2 { return verifier.Compare(this.Verifier); } + public void ChangePassword(string NewPassword) { + MySqlConnection conn = new MySqlConnection(Program.connStr); + conn.Open(); + byte[] salt = new byte[32]; + byte[] verifier = new byte[32]; + (salt, verifier) = Framework.Cryptography.SRP6.MakeRegistrationData(this.Username, NewPassword); + + string sql = "UPDATE auth.account SET salt=@salt, verifier=@verifier where username=@username"; + MySqlCommand cmd = new MySqlCommand(sql, conn); + cmd.Parameters.AddWithValue("username", Username); + cmd.Parameters.AddWithValue("salt", salt); + cmd.Parameters.AddWithValue("verifier", verifier); + cmd.ExecuteNonQuery(); + conn.Close(); + } } diff --git a/Pages/Account.cshtml b/Pages/Account.cshtml index 828c5d4..6a5411a 100644 --- a/Pages/Account.cshtml +++ b/Pages/Account.cshtml @@ -47,8 +47,27 @@
Username: @Model.UserAccount.Username
Email: @Model.UserAccount.Email
Last IP: @Model.UserAccount.LastIP
-Last Login: @Model.UserAccount.LastLogin.ToLocalTime()
+Last Login: @Model.UserAccount.LastLogin.ToLocalTime()
+ + + +