Skip to content

Commit

Permalink
Adds encoding to password to match the Analog app (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Guldborg authored Mar 5, 2024
1 parent 8de7138 commit 3684863
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Shifty.App/Services/AuthenticationService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<bool> 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)
{
Expand Down

0 comments on commit 3684863

Please sign in to comment.