Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Fix auth state redirect loop (#60)

Leendert de Borst4b12518ee4a1
diff --git a/src/AliasVault.WebApp/Pages/Base/PageBase.cs b/src/AliasVault.WebApp/Pages/Base/PageBase.cs
index 64b0c5b39..a9e6cb32f 100644
--- a/src/AliasVault.WebApp/Pages/Base/PageBase.cs
+++ b/src/AliasVault.WebApp/Pages/Base/PageBase.cs
@@ -100,7 +100,7 @@ public class PageBase : OwningComponentBase
protected async Task<string> GetUsernameAsync()
{
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
- return authState.User?.Identity?.Name ?? "[Unknown]";
+ return authState.User.Identity?.Name ?? "[Unknown]";
}
/// <summary>
@@ -126,7 +126,14 @@ public class PageBase : OwningComponentBase
/// </summary>
private async Task RedirectIfNoEncryptionKey()
{
- // Sanity check: check that encryption key is set. If not, redirect to lock screen.
+ // If not logged in, let the normal login process handle it.
+ var authState = await AuthStateProvider.GetAuthenticationStateAsync();
+ if (!authState.User.Identity?.IsAuthenticated ?? true)
+ {
+ return;
+ }
+
+ // Check that encryption key is set. If not, redirect to unlock screen.
if (string.IsNullOrEmpty(AuthService.GetEncryptionKeyAsBase64Async()) ||
AuthService.GetEncryptionKeyAsBase64Async() == "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
{
diff --git a/src/AliasVault.WebApp/Services/AliasClientDbService.cs b/src/AliasVault.WebApp/Services/AliasClientDbService.cs
index 7dfd57df9..84a227df1 100644
--- a/src/AliasVault.WebApp/Services/AliasClientDbService.cs
+++ b/src/AliasVault.WebApp/Services/AliasClientDbService.cs
@@ -27,11 +27,10 @@ public class AliasClientDbService
private readonly AuthService _authService;
private readonly IJSRuntime _jsRuntime;
private readonly HttpClient _httpClient;
- private readonly NavigationManager _navigationManager;
private AliasClientDbContext? _dbContext;
private Task _initializationTask;
- private bool _isSuccessfullyInitialized = false;
- private int _retryCount = 0;
+ private bool _isSuccessfullyInitialized;
+ private int _retryCount;
/// <summary>
/// Initializes a new instance of the <see cref="AliasClientDbService"/> class.
diff --git a/src/AliasVault.WebApp/wwwroot/css/tailwind.css b/src/AliasVault.WebApp/wwwroot/css/tailwind.css
index 1f8bf4529..9da74be88 100644
--- a/src/AliasVault.WebApp/wwwroot/css/tailwind.css
+++ b/src/AliasVault.WebApp/wwwroot/css/tailwind.css
@@ -607,6 +607,10 @@ video {
top: 2.5rem;
}
+.bottom-0 {
+ bottom: 0px;
+}
+
.z-10 {
z-index: 10;
}
@@ -631,6 +635,10 @@ video {
grid-column: 1 / -1;
}
+.m-4 {
+ margin: 1rem;
+}
+
.mx-3 {
margin-left: 0.75rem;
margin-right: 0.75rem;
@@ -726,6 +734,10 @@ video {
margin-top: 2rem;
}
+.ml-2 {
+ margin-left: 0.5rem;
+}
+
.block {
display: block;
}
@@ -790,6 +802,14 @@ video {
height: 100%;
}
+.h-24 {
+ height: 6rem;
+}
+
+.min-h-screen {
+ min-height: 100vh;
+}
+
.w-1\/2 {
width: 50%;
}
@@ -830,6 +850,10 @@ video {
width: 100%;
}
+.w-24 {
+ width: 6rem;
+}
+
.min-w-full {
min-width: 100%;
}
@@ -948,24 +972,18 @@ video {
margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));
}
-.space-y-6 > :not([hidden]) ~ :not([hidden]) {
- --tw-space-y-reverse: 0;
- margin-top: calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));
- margin-bottom: calc(1.5rem * var(--tw-space-y-reverse));
-}
-
-.space-y-8 > :not([hidden]) ~ :not([hidden]) {
- --tw-space-y-reverse: 0;
- margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));
- margin-bottom: calc(2rem * var(--tw-space-y-reverse));
-}
-
.space-y-4 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
}
+.space-y-6 > :not([hidden]) ~ :not([hidden]) {
+ --tw-space-y-reverse: 0;
+ margin-top: calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));
+ margin-bottom: calc(1.5rem * var(--tw-space-y-reverse));
+}
+
.divide-y > :not([hidden]) ~ :not([hidden]) {
--tw-divide-y-reverse: 0;
border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
@@ -1121,6 +1139,16 @@ video {
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
}
+.bg-gray-100 {
+ --tw-bg-opacity: 1;
+ background-color: rgb(243 244 246 / var(--tw-bg-opacity));
+}
+
+.bg-red-100 {
+ --tw-bg-opacity: 1;
+ background-color: rgb(254 226 226 / var(--tw-bg-opacity));
+}
+
.bg-opacity-50 {
--tw-bg-opacity: 0.5;
}
@@ -1251,6 +1279,11 @@ video {
line-height: 1rem;
}
+.text-lg {
+ font-size: 1.125rem;
+ line-height: 1.75rem;
+}
+
.font-bold {
font-weight: 700;
}
@@ -1342,6 +1375,20 @@ video {
color: rgb(255 255 255 / var(--tw-text-opacity));
}
+.text-blue-600 {
+ --tw-text-opacity: 1;
+ color: rgb(37 99 235 / var(--tw-text-opacity));
+}
+
+.text-red-700 {
+ --tw-text-opacity: 1;
+ color: rgb(185 28 28 / var(--tw-text-opacity));
+}
+
+.underline {
+ text-decoration-line: underline;
+}
+
.opacity-0 {
opacity: 0;
}
@@ -1578,6 +1625,11 @@ video {
background-color: rgb(239 68 68 / var(--tw-bg-opacity));
}
+.dark\:bg-red-900:is(.dark *) {
+ --tw-bg-opacity: 1;
+ background-color: rgb(127 29 29 / var(--tw-bg-opacity));
+}
+
.dark\:bg-opacity-80:is(.dark *) {
--tw-bg-opacity: 0.8;
}
@@ -1627,6 +1679,16 @@ video {
color: rgb(255 255 255 / var(--tw-text-opacity));
}
+.dark\:text-gray-700:is(.dark *) {
+ --tw-text-opacity: 1;
+ color: rgb(55 65 81 / var(--tw-text-opacity));
+}
+
+.dark\:text-red-300:is(.dark *) {
+ --tw-text-opacity: 1;
+ color: rgb(252 165 165 / var(--tw-text-opacity));
+}
+
.dark\:placeholder-gray-400:is(.dark *)::-moz-placeholder {
--tw-placeholder-opacity: 1;
color: rgb(156 163 175 / var(--tw-placeholder-opacity));