diff --git a/Shifty.App/Services/AuthenticationService.cs b/Shifty.App/Services/AuthenticationService.cs index e8d7bad..fa4f1aa 100644 --- a/Shifty.App/Services/AuthenticationService.cs +++ b/Shifty.App/Services/AuthenticationService.cs @@ -1,4 +1,7 @@ using System.Threading.Tasks; +using System; +using System.Security.Cryptography; +using System.Text; using Blazored.LocalStorage; using LanguageExt.UnsafeValueAccess; using Shifty.App.Authentication; @@ -19,9 +22,20 @@ public AuthenticationService(IAccountRepository accountRepository, CustomAuthSta _localStorage = storageService; } + private static string EncodePasscode(string passcode) + { + byte[] bytes = Encoding.UTF8.GetBytes(passcode); + using (SHA256 sha256 = SHA256.Create()) + { + byte[] passcodeHash = sha256.ComputeHash(bytes); + return Convert.ToBase64String(passcodeHash); + } + } + public async Task LoginUser(string username, string password) { - var either = await _accountRepository.LoginAsync(username, password); + var encodedPassword = EncodePasscode(password); + var either = await _accountRepository.LoginAsync(username, encodedPassword); if (either.IsLeft) {