Use new Auth API
This commit is contained in:
parent
38e76d3539
commit
79c17f75cd
16 changed files with 94 additions and 150 deletions
|
@ -1,31 +1,5 @@
|
|||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Website.Data.States;
|
||||
|
||||
namespace Website.Models {
|
||||
namespace Website.Models {
|
||||
public class User {
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(UserState state) {
|
||||
Username = state.User_Email;
|
||||
Password = state.User_Password;
|
||||
}
|
||||
|
||||
public bool ValidatePassword(string password) {
|
||||
using (var sha256 = SHA256.Create()) {
|
||||
var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(password));
|
||||
|
||||
var builder = new StringBuilder();
|
||||
foreach (var b in hash)
|
||||
builder.Append(b.ToString("x2"));
|
||||
var hashString = builder.ToString();
|
||||
|
||||
return hashString == Password;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue