Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Fix admin bugs (#113)
Leendert de Borstbf68e380bcbc
diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razorindex 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</li><li><p class="text-gray-700 dark:text-gray-300">Scan the QR Code or enter this key <kbd class="px-2 py-1.5 text-xs font-semibold text-gray-800 bg-gray-100 border border-gray-200 rounded-lg dark:bg-gray-600 dark:text-gray-100 dark:border-gray-500">@sharedKey</kbd> into your two factor authenticator app. Spaces and casing do not matter.</p>- <div class="mt-2 p-4 bg-blue-100 text-blue-700 rounded-md dark:bg-blue-900 dark:text-blue-300">- Learn how to <a href="https://go.microsoft.com/fwlink/?Linkid=852423" class="text-blue-800 hover:underline dark:text-blue-200">enable QR code generation</a>.- </div><div id="authenticator-uri" data-url="@authenticatorUri" class="mt-4"></div></li><li>@@ -129,8 +126,8 @@ elsesharedKey = 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 @@ elsereturn 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.razorindex 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();/// <inheritdoc />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.razorindex 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<AdminUser> UserManager-@inject SignInManager<AdminUser> SignInManager@inject ILogger<ResetAuthenticator> Logger<LayoutPageTitle>Reset authenticator key</LayoutPageTitle>@@ -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.csindex 7ca0b4e31..8c0cd2781 100644--- a/src/AliasVault.Admin/StartupTasks.cs+++ b/src/AliasVault.Admin/StartupTasks.cs@@ -52,6 +52,7 @@ public static class StartupTasksawait 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;