diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razor
index 60e466bb0..0ecb4d062 100644
--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razor
+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razor
@@ -35,9 +35,6 @@ else
Scan the QR Code or enter this key @sharedKey into your two factor authenticator app. Spaces and casing do not matter.
-
@@ -129,8 +126,8 @@ else
sharedKey = FormatKey(unformattedKey!);
- var email = await UserManager.GetEmailAsync(user);
- authenticatorUri = GenerateQrCodeUri(email!, unformattedKey!);
+ var username = await UserManager.GetUserNameAsync(user);
+ authenticatorUri = GenerateQrCodeUri(username!, unformattedKey!);
}
private string FormatKey(string unformattedKey)
@@ -151,13 +148,13 @@ else
return result.ToString().ToLowerInvariant();
}
- private string GenerateQrCodeUri(string email, string unformattedKey)
+ private string GenerateQrCodeUri(string username, string unformattedKey)
{
return string.Format(
CultureInfo.InvariantCulture,
AuthenticatorUriFormat,
UrlEncoder.Encode("AliasVault Admin"),
- UrlEncoder.Encode(email),
+ UrlEncoder.Encode(username),
unformattedKey);
}
diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/Index.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/Index.razor
index c2a52eb99..fe21aa3cc 100644
--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/Index.razor
+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/Index.razor
@@ -33,7 +33,7 @@
private string? username;
private string? phoneNumber;
- [SupplyParameterFromForm] private InputModel Input { get; } = new();
+ [SupplyParameterFromForm] private InputModel Input { get; set; } = new();
///
protected override async Task OnInitializedAsync()
diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/ResetAuthenticator.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/ResetAuthenticator.razor
index a05f7fe37..48ed7d98c 100644
--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/ResetAuthenticator.razor
+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/ResetAuthenticator.razor
@@ -3,7 +3,6 @@
@using Microsoft.AspNetCore.Identity
@inject UserManager UserManager
-@inject SignInManager SignInManager
@inject ILogger Logger
Reset authenticator key
@@ -36,12 +35,10 @@
var userId = await UserManager.GetUserIdAsync(UserService.User());
Logger.LogInformation("User with ID '{UserId}' has reset their authentication app key.", userId);
- await SignInManager.RefreshSignInAsync(UserService.User());
-
- GlobalNotificationService.AddSuccessMessage("Your authenticator app key has been reset, you will need to configure your authenticator app using the new key.");
+ GlobalNotificationService.AddSuccessMessage("Your authenticator app key has been reset, you will need to re-configure your authenticator app using the new key.", true);
NavigationService.RedirectTo(
- "account/manage/enable-authenticator");
+ "account/manage/2fa");
}
}
diff --git a/src/AliasVault.Admin/StartupTasks.cs b/src/AliasVault.Admin/StartupTasks.cs
index 7ca0b4e31..8c0cd2781 100644
--- a/src/AliasVault.Admin/StartupTasks.cs
+++ b/src/AliasVault.Admin/StartupTasks.cs
@@ -52,6 +52,7 @@ public static class StartupTasks
await userManager.CreateAsync(adminUser);
adminUser.PasswordHash = adminPasswordHash;
+ adminUser.LastPasswordChanged = DateTime.UtcNow;
await userManager.UpdateAsync(adminUser);
Console.WriteLine("Admin user created.");
@@ -60,7 +61,7 @@ public static class StartupTasks
{
// Check if the password hash is different AND the password in .env file is newer than the password of user.
// If so, update the password hash of the user in the database so it matches the one in the .env file.
- if (adminUser.PasswordHash != config.AdminPasswordHash && config.LastPasswordChanged > adminUser.LastPasswordChanged)
+ if (adminUser.PasswordHash != config.AdminPasswordHash && (adminUser.LastPasswordChanged is null || config.LastPasswordChanged > adminUser.LastPasswordChanged))
{
// The password has been changed in the .env file, update the user's password hash.
adminUser.PasswordHash = config.AdminPasswordHash;