Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Refactor codestyle issues (#113)
Leendert de Borstb2e344c523c1
diff --git a/src/AliasGenerators/Password/IPasswordGenerator.cs b/src/AliasGenerators/Password/IPasswordGenerator.csindex 3f5e5e265..1473fe7bc 100644--- a/src/AliasGenerators/Password/IPasswordGenerator.cs+++ b/src/AliasGenerators/Password/IPasswordGenerator.cs@@ -4,7 +4,7 @@// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.// </copyright>//------------------------------------------------------------------------namespace AliasGenerators.Implementations;+namespace AliasGenerators.Password;/// <summary>/// Interface for password generators.diff --git a/src/AliasGenerators/Password/Implementations/SpamOkPasswordGenerator.cs b/src/AliasGenerators/Password/Implementations/SpamOkPasswordGenerator.csindex a2e127437..9c68b5995 100644--- a/src/AliasGenerators/Password/Implementations/SpamOkPasswordGenerator.cs+++ b/src/AliasGenerators/Password/Implementations/SpamOkPasswordGenerator.cs@@ -4,9 +4,10 @@// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.// </copyright>//-----------------------------------------------------------------------+namespace AliasGenerators.Password.Implementations;-using AliasGenerators.Implementations;+using AliasGenerators.Password;/// <summary>/// Implementation of IPasswordGenerator which generates passwords using the SpamOK library.diff --git a/src/AliasVault.Admin/AliasVault.Admin.csproj b/src/AliasVault.Admin/AliasVault.Admin.csprojindex 7549adcac..c47dfb842 100644--- a/src/AliasVault.Admin/AliasVault.Admin.csproj+++ b/src/AliasVault.Admin/AliasVault.Admin.csproj@@ -23,6 +23,10 @@<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.6"/><PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6"/><PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6"/>+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference></ItemGroup><ItemGroup>diff --git a/src/AliasVault.Admin/Auth/Layout/AuthLayout.razor b/src/AliasVault.Admin/Auth/Layout/AuthLayout.razorindex 23413718d..4a125b766 100644--- a/src/AliasVault.Admin/Auth/Layout/AuthLayout.razor+++ b/src/AliasVault.Admin/Auth/Layout/AuthLayout.razor@@ -17,6 +17,13 @@</div>@code {+ /// <inheritdoc />+ public void Dispose()+ {+ NavigationManager.LocationChanged -= OnLocationChanged;+ }++ /// <inheritdoc />protected override void OnInitialized(){NavigationManager.LocationChanged += OnLocationChanged;@@ -26,9 +33,4 @@{StateHasChanged();}-- public void Dispose()- {- NavigationManager.LocationChanged -= OnLocationChanged;- }}diff --git a/src/AliasVault.Admin/Auth/Pages/AuthBase.cs b/src/AliasVault.Admin/Auth/Pages/AuthBase.csindex 7f2fb18db..1f87d306d 100644--- a/src/AliasVault.Admin/Auth/Pages/AuthBase.cs+++ b/src/AliasVault.Admin/Auth/Pages/AuthBase.cs@@ -1,10 +1,15 @@-using AliasVault.Admin.Main.Components.Alerts;+//-----------------------------------------------------------------------+// <copyright file="AuthBase.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasVault.Admin.Auth.Pages;using AliasServerDb;+using AliasVault.Admin.Main.Components.Alerts;using AliasVault.Admin.Services;-using Microsoft.AspNetCore.Authorization;using Microsoft.AspNetCore.Components;using Microsoft.AspNetCore.Components.Authorization;using Microsoft.AspNetCore.Identity;@@ -47,9 +52,9 @@ public class AuthBase : OwningComponentBaseprotected AuthenticationStateProvider AuthenticationStateProvider { get; set; } = null!;/// <summary>- /// Object which holds server validation errors to show in the UI.+ /// Gets or sets object which holds server validation errors to show in the UI./// </summary>- protected ServerValidationErrors ServerValidationErrors = new();+ protected ServerValidationErrors ServerValidationErrors { get; set; } = new();/// <inheritdoc />protected override async Task OnInitializedAsync()diff --git a/src/AliasVault.Admin/Auth/Pages/Login.razor b/src/AliasVault.Admin/Auth/Pages/Login.razorindex df3e1ea1b..3a42f10ef 100644--- a/src/AliasVault.Admin/Auth/Pages/Login.razor+++ b/src/AliasVault.Admin/Auth/Pages/Login.razor@@ -42,6 +42,7 @@[SupplyParameterFromQuery] private string? ReturnUrl { get; set; }+ /// <inheritdoc />protected override async Task OnInitializedAsync(){await base.OnInitializedAsync();@@ -52,7 +53,10 @@}}- public async Task LoginUser()+ /// <summary>+ /// Logs in the user.+ /// </summary>+ protected async Task LoginUser(){ServerValidationErrors.Clear();diff --git a/src/AliasVault.Admin/Auth/Pages/LoginWith2fa.razor b/src/AliasVault.Admin/Auth/Pages/LoginWith2fa.razorindex 0017e7ad6..33acae856 100644--- a/src/AliasVault.Admin/Auth/Pages/LoginWith2fa.razor+++ b/src/AliasVault.Admin/Auth/Pages/LoginWith2fa.razor@@ -45,6 +45,7 @@[SupplyParameterFromQuery] private bool RememberMe { get; set; }+ /// <inheritdoc />protected override async Task OnInitializedAsync(){await base.OnInitializedAsync();@@ -54,6 +55,9 @@throw new InvalidOperationException("Unable to load two-factor authentication user.");}+ /// <summary>+ /// Submits the form.+ /// </summary>private async Task OnValidSubmitAsync(){ServerValidationErrors.Clear();diff --git a/src/AliasVault.Admin/Auth/Pages/LoginWithRecoveryCode.razor b/src/AliasVault.Admin/Auth/Pages/LoginWithRecoveryCode.razorindex f32272310..60cd065ee 100644--- a/src/AliasVault.Admin/Auth/Pages/LoginWithRecoveryCode.razor+++ b/src/AliasVault.Admin/Auth/Pages/LoginWithRecoveryCode.razor@@ -32,6 +32,7 @@[SupplyParameterFromQuery] private string? ReturnUrl { get; set; }+ /// <inheritdoc />protected override async Task OnInitializedAsync(){// Ensure the user has gone through the username & password screen first@@ -39,6 +40,9 @@throw new InvalidOperationException("Unable to load two-factor authentication user.");}+ /// <summary>+ /// Submits the form.+ /// </summary>private async Task OnValidSubmitAsync(){ServerValidationErrors.Clear();diff --git a/src/AliasVault.Admin/Auth/Pages/Logout.razor b/src/AliasVault.Admin/Auth/Pages/Logout.razorindex 0fef661c2..d591278a0 100644--- a/src/AliasVault.Admin/Auth/Pages/Logout.razor+++ b/src/AliasVault.Admin/Auth/Pages/Logout.razor@@ -2,6 +2,7 @@@inject GlobalNotificationService GlobalNotificationService@code {+ /// <inheritdoc />protected override async Task OnInitializedAsync(){// Sign out the user.diff --git a/src/AliasVault.Admin/Auth/Providers/RevalidatingAuthenticationStateProvider.cs b/src/AliasVault.Admin/Auth/Providers/RevalidatingAuthenticationStateProvider.csindex ca84e2765..ca7bd4ea7 100644--- a/src/AliasVault.Admin/Auth/Providers/RevalidatingAuthenticationStateProvider.cs+++ b/src/AliasVault.Admin/Auth/Providers/RevalidatingAuthenticationStateProvider.cs@@ -1,3 +1,10 @@+//-----------------------------------------------------------------------+// <copyright file="RevalidatingAuthenticationStateProvider.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasVault.Admin.Auth.Providers;using System.Security.Claims;@@ -11,9 +18,9 @@ using Microsoft.Extensions.Options;/// This is a server-side AuthenticationStateProvider that revalidates the security stamp for the connected user/// every 30 minutes an interactive circuit is connected./// </summary>-/// <param name="loggerFactory"></param>-/// <param name="scopeFactory"></param>-/// <param name="options"></param>+/// <param name="loggerFactory">ILoggerFactory instance.</param>+/// <param name="scopeFactory">IServiceScopeFactory instance.</param>+/// <param name="options">IOptions instance.</param>internal sealed class RevalidatingAuthenticationStateProvider(ILoggerFactory loggerFactory,IServiceScopeFactory scopeFactory,@@ -21,7 +28,7 @@ internal sealed class RevalidatingAuthenticationStateProvider(: RevalidatingServerAuthenticationStateProvider(loggerFactory){/// <summary>- /// The revalidation interval.+ /// Gets the revalidation interval./// </summary>protected override TimeSpan RevalidationInterval => TimeSpan.FromMinutes(30);@@ -40,23 +47,21 @@ internal sealed class RevalidatingAuthenticationStateProvider(return await ValidateSecurityStampAsync(userManager, authenticationState.User);}- private async Task<bool> ValidateSecurityStampAsync(UserManager<AdminUser> userManager,- ClaimsPrincipal principal)+ private async Task<bool> ValidateSecurityStampAsync(UserManager<AdminUser> userManager, ClaimsPrincipal principal){var user = await userManager.GetUserAsync(principal);if (user is null){return false;}- else if (!userManager.SupportsUserSecurityStamp)++ if (!userManager.SupportsUserSecurityStamp){return true;}- else- {- var principalStamp = principal.FindFirstValue(options.Value.ClaimsIdentity.SecurityStampClaimType);- var userStamp = await userManager.GetSecurityStampAsync(user);- return principalStamp == userStamp;- }++ var principalStamp = principal.FindFirstValue(options.Value.ClaimsIdentity.SecurityStampClaimType);+ var userStamp = await userManager.GetSecurityStampAsync(user);+ return principalStamp == userStamp;}}diff --git a/src/AliasVault.Admin/Main/Components/Layout/LayoutPageTitle.razor b/src/AliasVault.Admin/Main/Components/Layout/LayoutPageTitle.razorindex 0d00a1f83..b858de44d 100644--- a/src/AliasVault.Admin/Main/Components/Layout/LayoutPageTitle.razor+++ b/src/AliasVault.Admin/Main/Components/Layout/LayoutPageTitle.razor@@ -1,6 +1,9 @@<PageTitle>@ChildContent - AliasVault Admin</PageTitle>@code {+ /// <summary>+ /// Child content.+ /// </summary>[Parameter]public RenderFragment ChildContent { get; set; } = default!;}diff --git a/src/AliasVault.Admin/Main/Components/RedirectToLogin.razor b/src/AliasVault.Admin/Main/Components/RedirectToLogin.razorindex 1557eb283..63af3de90 100644--- a/src/AliasVault.Admin/Main/Components/RedirectToLogin.razor+++ b/src/AliasVault.Admin/Main/Components/RedirectToLogin.razor@@ -1,6 +1,7 @@@inject NavigationManager NavigationManager@code {+ /// <inheritdoc />protected override void OnInitialized(){NavigationManager.NavigateTo($"user/login?returnUrl={Uri.EscapeDataString(NavigationManager.Uri)}", forceLoad: true);diff --git a/src/AliasVault.Admin/Main/Layout/MainLayout.razor b/src/AliasVault.Admin/Main/Layout/MainLayout.razorindex 7c456c452..95188e3e8 100644--- a/src/AliasVault.Admin/Main/Layout/MainLayout.razor+++ b/src/AliasVault.Admin/Main/Layout/MainLayout.razor@@ -8,7 +8,7 @@<main>@Body</main>- <Footer />+ <Footer></Footer></div></div>@@ -19,23 +19,21 @@</div>@code {- private string? currentUrl;+ /// <inheritdoc />+ public void Dispose()+ {+ NavigationManager.LocationChanged -= OnLocationChanged;+ }+ /// <inheritdoc />protected override void OnInitialized(){- currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);NavigationManager.LocationChanged += OnLocationChanged;}private void OnLocationChanged(object? sender, LocationChangedEventArgs e){- currentUrl = NavigationManager.ToBaseRelativePath(e.Location);StateHasChanged();}-- public void Dispose()- {- NavigationManager.LocationChanged -= OnLocationChanged;- }}diff --git a/src/AliasVault.Admin/Main/Models/BreadcrumbItem.cs b/src/AliasVault.Admin/Main/Models/BreadcrumbItem.csindex 0335c73ca..2e18b9a56 100644--- a/src/AliasVault.Admin/Main/Models/BreadcrumbItem.cs+++ b/src/AliasVault.Admin/Main/Models/BreadcrumbItem.cs@@ -1,7 +1,24 @@+//-----------------------------------------------------------------------+// <copyright file="BreadcrumbItem.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasVault.Admin.Main.Models;+/// <summary>+/// Breadcrumb item model.+/// </summary>public class BreadcrumbItem{+ /// <summary>+ /// Gets or sets the display name.+ /// </summary>public string? DisplayName { get; set; }++ /// <summary>+ /// Gets or sets the URL.+ /// </summary>public string? Url { get; set; }}diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/ChangePassword.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/ChangePassword.razorindex ce47ed85d..89f513d2e 100644--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/ChangePassword.razor+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/ChangePassword.razor@@ -43,6 +43,7 @@[SupplyParameterFromForm] private InputModel Input { get; set; } = new();+ /// <inheritdoc />protected override async Task OnInitializedAsync(){hasPassword = await UserManager.HasPasswordAsync(UserService.User());diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/Components/ShowRecoveryCodes.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/Components/ShowRecoveryCodes.razorindex c8316022b..f9d3549a4 100644--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/Components/ShowRecoveryCodes.razor+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/Components/ShowRecoveryCodes.razor@@ -1,25 +1,25 @@-<h3>Recovery codes</h3>-<div class="alert alert-warning" role="alert">- <p>- <strong>Put these codes in a safe place.</strong>+<h3 class="text-lg font-medium">Recovery codes</h3>+<div class="bg-primary-100 border-l-4 border-primary-500 text-primary-700 p-4" role="alert">+ <p class="font-semibold">+ Put these codes in a safe place.</p><p>If you lose your device and don't have the recovery codes you will lose access to your account.</p></div>-<div class="row">- <div class="col-md-12">- @foreach (var recoveryCode in RecoveryCodes)- {- <div>- <code class="recovery-code">@recoveryCode</code>- </div>- }+<div class="grid grid-cols-1">+ @foreach (var recoveryCode in RecoveryCodes)+ {+ <div>+ <code class="block p-2 bg-primary-200 rounded">@recoveryCode</code></div>+ }</div>@code {- [Parameter] public string[] RecoveryCodes { get; set; } = [];-- [Parameter] public string? StatusMessage { get; set; }+ /// <summary>+ /// The recovery codes to show.+ /// </summary>+ [Parameter]+ public string[] RecoveryCodes { get; set; } = [];}diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/Disable2fa.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/Disable2fa.razorindex d0daae01d..a4486ed3b 100644--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/Disable2fa.razor+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/Disable2fa.razor@@ -27,6 +27,7 @@</div>@code {+ /// <inheritdoc />protected override async Task OnInitializedAsync(){if (!await UserManager.GetTwoFactorEnabledAsync(UserService.User()))@@ -37,8 +38,8 @@private async Task OnSubmitAsync(){- var disable2faResult = await UserManager.SetTwoFactorEnabledAsync(UserService.User(), false);- if (!disable2faResult.Succeeded)+ var disable2FaResult = await UserManager.SetTwoFactorEnabledAsync(UserService.User(), false);+ if (!disable2FaResult.Succeeded){throw new InvalidOperationException("Unexpected error occurred disabling 2FA.");}diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razorindex 6e447eec0..60e466bb0 100644--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razor+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/EnableAuthenticator.razor@@ -76,6 +76,7 @@ else[SupplyParameterFromForm] private InputModel Input { get; set; } = new();+ /// <inheritdoc />protected override async Task OnInitializedAsync(){await base.OnInitializedAsync();diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/GenerateRecoveryCodes.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/GenerateRecoveryCodes.razorindex 91b99170d..b33340c08 100644--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/GenerateRecoveryCodes.razor+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/GenerateRecoveryCodes.razor@@ -9,7 +9,7 @@@if (recoveryCodes is not null){- <ShowRecoveryCodes RecoveryCodes="recoveryCodes.ToArray()" StatusMessage="@message"/>+ <ShowRecoveryCodes RecoveryCodes="recoveryCodes.ToArray()"/>}else{@@ -35,9 +35,9 @@ else}@code {- private string? message;private IEnumerable<string>? recoveryCodes;+ /// <inheritdoc />protected override async Task OnInitializedAsync(){await base.OnInitializedAsync();@@ -53,7 +53,7 @@ else{var userId = await UserManager.GetUserIdAsync(UserService.User());recoveryCodes = await UserManager.GenerateNewTwoFactorRecoveryCodesAsync(UserService.User(), 10);- message = "You have generated new recovery codes.";+ GlobalNotificationService.AddSuccessMessage("You have generated new recovery codes.");Logger.LogInformation("User with ID '{UserId}' has generated new 2FA recovery codes.", userId);}diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/Index.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/Index.razorindex f83433687..975574e41 100644--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/Index.razor+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/Index.razor@@ -33,8 +33,9 @@private string? username;private string? phoneNumber;- [SupplyParameterFromForm] private InputModel Input { get; set; } = new();+ [SupplyParameterFromForm] private InputModel Input { get; } = new();+ /// <inheritdoc />protected override async Task OnInitializedAsync(){await base.OnInitializedAsync();diff --git a/src/AliasVault.Admin/Main/Pages/Account/Manage/TwoFactorAuthentication.razor b/src/AliasVault.Admin/Main/Pages/Account/Manage/TwoFactorAuthentication.razorindex 6e7dbd65f..b10fc8b1b 100644--- a/src/AliasVault.Admin/Main/Pages/Account/Manage/TwoFactorAuthentication.razor+++ b/src/AliasVault.Admin/Main/Pages/Account/Manage/TwoFactorAuthentication.razor@@ -7,7 +7,7 @@<LayoutPageTitle>Two-factor authentication (2FA)</LayoutPageTitle>-@if (is2faEnabled)+@if (is2FaEnabled){<div class="mx-auto mt-8 p-6 bg-white dark:bg-gray-800 rounded-lg shadow-md"><h3 class="text-xl font-bold text-gray-900 dark:text-white mb-4">Two-factor authentication (2FA)</h3>@@ -65,23 +65,15 @@@code {private bool hasAuthenticator;private int recoveryCodesLeft;- private bool is2faEnabled;+ private bool is2FaEnabled;+ /// <inheritdoc />protected override async Task OnInitializedAsync(){await base.OnInitializedAsync();hasAuthenticator = await UserManager.GetAuthenticatorKeyAsync(UserService.User()) is not null;- is2faEnabled = await UserManager.GetTwoFactorEnabledAsync(UserService.User());+ is2FaEnabled = await UserManager.GetTwoFactorEnabledAsync(UserService.User());recoveryCodesLeft = await UserManager.CountRecoveryCodesAsync(UserService.User());}-- private async Task OnSubmitForgetBrowserAsync()- {- await SignInManager.ForgetTwoFactorClientAsync();-- // Refresh current page.- NavigationService.RedirectTo(string.Empty, true);- }-}diff --git a/src/AliasVault.Admin/Main/Pages/Emails.razor b/src/AliasVault.Admin/Main/Pages/Emails.razorindex dca4ebf26..dc93d1cbd 100644--- a/src/AliasVault.Admin/Main/Pages/Emails.razor+++ b/src/AliasVault.Admin/Main/Pages/Emails.razor@@ -63,8 +63,9 @@ else@code {private bool IsLoading { get; set; } = true;- private List<Email> EmailList { get; set; } = new List<Email>();+ private List<Email> EmailList { get; set; } = [];+ /// <inheritdoc />protected override async Task OnAfterRenderAsync(bool firstRender){if (firstRender)diff --git a/src/AliasVault.Admin/Main/Pages/Error.razor b/src/AliasVault.Admin/Main/Pages/Error.razorindex 71de04bbe..8313ecd82 100644--- a/src/AliasVault.Admin/Main/Pages/Error.razor+++ b/src/AliasVault.Admin/Main/Pages/Error.razor@@ -30,6 +30,7 @@private string? RequestId { get; set; }private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);+ /// <inheritdoc />protected override void OnInitialized() =>RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;diff --git a/src/AliasVault.Admin/Main/Pages/MainBase.cs b/src/AliasVault.Admin/Main/Pages/MainBase.csindex b6f9c6a62..cb6fe7dcb 100644--- a/src/AliasVault.Admin/Main/Pages/MainBase.cs+++ b/src/AliasVault.Admin/Main/Pages/MainBase.cs@@ -1,4 +1,11 @@-namespace AliasVault.Admin.Main.Pages;+//-----------------------------------------------------------------------+// <copyright file="MainBase.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.Admin.Main.Pages;using AliasServerDb;using AliasVault.Admin.Main.Models;@@ -15,55 +22,57 @@ using Microsoft.JSInterop;[Authorize]public class MainBase : OwningComponentBase{- private bool _parametersInitialSet;-+ /// <summary>+ /// Gets or sets the NavigationService instance responsible for handling navigation, replaces the default NavigationManager.+ /// </summary>[Inject]public NavigationService NavigationService { get; set; } = null!;+ /// <summary>+ /// Gets or sets the UserService instance responsible for handling user data.+ /// </summary>[Inject]protected UserService UserService { get; set; } = null!;+ /// <summary>+ /// Gets or sets the global notification service for showing notifications throughout the app.+ /// </summary>[Inject]protected GlobalNotificationService GlobalNotificationService { get; set; } = null!;+ /// <summary>+ /// Gets or sets the JS invoke service for calling JS functions from C#.+ /// </summary>[Inject]- public JsInvokeService JsInvokeService { get; set; } = null!;+ protected JsInvokeService JsInvokeService { get; set; } = null!;+ /// <summary>+ /// Gets or sets the AliasServerDbContext instance.+ /// </summary>[Inject]- public AliasServerDbContext DbContext { get; set; } = null!;+ protected AliasServerDbContext DbContext { get; set; } = null!;+ /// <summary>+ /// Gets or sets the injected JSRuntime instance.+ /// </summary>[Inject]- public IJSRuntime Js { get; set; } = null!;+ protected IJSRuntime Js { get; set; } = null!;/// <summary>- /// Contains the breadcrumb items for the page. A default set of breadcrumbs is added in the parent OnInitialized method.+ /// Gets the breadcrumb items for the page. A default set of breadcrumbs is added in the parent OnInitialized method./// </summary>- protected List<BreadcrumbItem> BreadcrumbItems { get; set; } = new List<BreadcrumbItem>();+ protected List<BreadcrumbItem> BreadcrumbItems { get; } = new();+ /// <inheritdoc />protected override async Task OnInitializedAsync(){- if (!await AccessCheck())- {- return;- }-await base.OnInitializedAsync();- _parametersInitialSet = false;- // Add base breadcrumbs- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Home", Url = NavigationService.BaseUri });+ // Load the current user.+ await UserService.LoadCurrentUserAsync();- // Call the GenericAccessCheckAsync method and halt execution if a redirect is required.- var verifyAccessCheckTask = await AccessCheckService.GenericAccessCheckAsync(UserService);- if (verifyAccessCheckTask != true)- {- // Keep the page from loading if the user is not authorized by calling an infinite loop.- // We wait for navigation to happen during the infinite loop.- while (true)- {- await Task.Delay(1000);- }- }+ // Add base breadcrumbs.+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Home", Url = NavigationService.BaseUri });}/// <inheritdoc />@@ -72,52 +81,6 @@ public class MainBase : OwningComponentBaseawait base.OnAfterRenderAsync(firstRender);}- /// <summary>- /// Issue a redirect to the login page if the user is not logged in.- /// </summary>- /// <returns>Boolean whether user has access to the current page.</returns>- protected async Task<bool> AccessCheck()- {- // Call the GenericAccessCheckAsync method and halt execution if a redirect is required.- var verifyAccessCheckTask = await AccessCheckService.GenericAccessCheckAsync(UserService);- if (verifyAccessCheckTask != true)- {- // Keep the page from loading if the user is not authorized by calling an infinite loop.- // We wait for navigation to happen during the infinite loop.- while (true)- {- await Task.Delay(1000);- return false;- }- }-- return true;- }-- protected override async Task OnParametersSetAsync()- {- await base.OnParametersSetAsync();-- // This is needed to prevent the OnParametersSetAsync method from running together with OnInitialized on initial page load.- if (!_parametersInitialSet)- {- _parametersInitialSet = true;- return;- }-- // Call the GenericAccessCheckAsync method and halt execution if a redirect is required.- var verifyAccessCheckTask = await AccessCheckService.GenericAccessCheckAsync(UserService);- if (verifyAccessCheckTask != true)- {- // Keep the page from loading if the user is not authorized by calling an infinite loop.- // We wait for navigation to happen during the infinite loop.- while (true)- {- await Task.Delay(1000);- }- }- }-/// <summary>/// Gets the username from the authentication state asynchronously./// </summary>diff --git a/src/AliasVault.Admin/Program.cs b/src/AliasVault.Admin/Program.csindex 1158fbe73..759c2d29f 100644--- a/src/AliasVault.Admin/Program.cs+++ b/src/AliasVault.Admin/Program.cs@@ -1,14 +1,21 @@+//-----------------------------------------------------------------------+// <copyright file="Program.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+using System.Data.Common;using System.Globalization;using AliasServerDb;using AliasVault.Admin;-using Microsoft.AspNetCore.Components.Authorization;-using Microsoft.AspNetCore.Identity;-using Microsoft.EntityFrameworkCore;using AliasVault.Admin.Auth.Providers;using AliasVault.Admin.Main;using AliasVault.Admin.Services;+using Microsoft.AspNetCore.Components.Authorization;+using Microsoft.AspNetCore.Identity;using Microsoft.Data.Sqlite;+using Microsoft.EntityFrameworkCore;var builder = WebApplication.CreateBuilder(args);@@ -95,7 +102,6 @@ if (app.Environment.IsDevelopment())else{app.UseExceptionHandler("/Error", createScopeForErrors: true);- // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.app.UseHsts();}@@ -109,6 +115,11 @@ app.MapRazorComponents<App>()using (var scope = app.Services.CreateScope()){+ var container = scope.ServiceProvider;+ var db = container.GetRequiredService<AliasServerDbContext>();++ await db.Database.MigrateAsync();+await StartupTasks.CreateRolesIfNotExist(scope.ServiceProvider);await StartupTasks.SetAdminUser(scope.ServiceProvider);}diff --git a/src/AliasVault.Admin/Services/AccessCheckService.cs b/src/AliasVault.Admin/Services/AccessCheckService.csdeleted file mode 100644index 09480f229..000000000--- a/src/AliasVault.Admin/Services/AccessCheckService.cs+++ /dev/null@@ -1,23 +0,0 @@-namespace AliasVault.Admin.Services;--/// <summary>-/// Access check service to verify if the user is logged in and has a confirmed email.-/// </summary>-public class AccessCheckService-{- public static async Task<bool> GenericAccessCheckAsync(UserService userService)- {- await userService.LoadCurrentUserAsync();-- if (userService.UserLoaded)- {- // User is logged in and email is confirmed.- return true;- }- else- {- // Redirect is handled by the Main/Routes.razor file.- return true;- }- }-}diff --git a/src/AliasVault.Admin/Services/JSInvokeService.cs b/src/AliasVault.Admin/Services/JSInvokeService.csindex 3d99dcdda..efc8d5646 100644--- a/src/AliasVault.Admin/Services/JSInvokeService.cs+++ b/src/AliasVault.Admin/Services/JSInvokeService.cs@@ -1,3 +1,10 @@+//-----------------------------------------------------------------------+// <copyright file="JSInvokeService.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasVault.Admin.Services;using Microsoft.JSInterop;@@ -5,19 +12,16 @@ using Microsoft.JSInterop;/// <summary>/// Service for invoking JavaScript functions from C#./// </summary>-public class JsInvokeService+public class JsInvokeService(IJSRuntime js){- private IJSRuntime Js { get; }-/// <summary>- /// Initializes a new instance of the <see cref="JsInvokeService"/> class.+ /// Invoke a JavaScript function with retry and exponential backoff./// </summary>- /// <param name="js">The IJSRuntime object.</param>- public JsInvokeService(IJSRuntime js)- {- Js = js;- }-+ /// <param name="functionName">The JS function name to call.</param>+ /// <param name="initialDelay">Initial delay before calling the function.</param>+ /// <param name="maxAttempts">Maximum attempts before giving up.</param>+ /// <param name="args">Arguments to pass on to the javascript function.</param>+ /// <returns>Async Task.</returns>public async Task RetryInvokeAsync(string functionName, TimeSpan initialDelay, int maxAttempts, params object[] args){TimeSpan delay = initialDelay;@@ -25,10 +29,10 @@ public class JsInvokeService{try{- bool isDefined = await this.Js.InvokeAsync<bool>("isFunctionDefined", functionName);+ bool isDefined = await js.InvokeAsync<bool>("isFunctionDefined", functionName);if (isDefined){- await this.Js.InvokeVoidAsync(functionName, args);+ await js.InvokeVoidAsync(functionName, args);return; // Successfully called the JS function, exit the method}}diff --git a/src/AliasVault.Admin/Services/NavigationService.cs b/src/AliasVault.Admin/Services/NavigationService.csindex 784d82dfa..5bd19133e 100644--- a/src/AliasVault.Admin/Services/NavigationService.cs+++ b/src/AliasVault.Admin/Services/NavigationService.cs@@ -1,8 +1,15 @@-using Microsoft.AspNetCore.Components;-using Microsoft.AspNetCore.Components.Routing;+//-----------------------------------------------------------------------+// <copyright file="NavigationService.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasVault.Admin.Services;+using Microsoft.AspNetCore.Components;+using Microsoft.AspNetCore.Components.Routing;+/// <summary>/// Navigation helper service./// </summary>@@ -10,30 +17,40 @@ public class NavigationService{private readonly NavigationManager _navigationManager;- private string CurrentPath => _navigationManager.ToAbsoluteUri(_navigationManager.Uri).GetLeftPart(UriPartial.Path);+ /// <summary>+ /// Initializes a new instance of the <see cref="NavigationService"/> class.+ /// </summary>+ /// <param name="navigationManager">NavigationManager instance.</param>+ public NavigationService(NavigationManager navigationManager)+ {+ _navigationManager = navigationManager;+ _navigationManager.LocationChanged += (sender, args) => { LocationChanged?.Invoke(sender, args); };+ }/// <summary>- /// Redirect to the current page.+ /// Location changed event./// </summary>- public void RedirectToCurrentPage() => RedirectTo(CurrentPath);+ public event EventHandler<LocationChangedEventArgs>? LocationChanged;+ /// <summary>+ /// Gets the Base URI.+ /// </summary>public string BaseUri => _navigationManager.BaseUri;++ /// <summary>+ /// Gets the URI.+ /// </summary>public string Uri => _navigationManager.Uri;- public event EventHandler<LocationChangedEventArgs>? LocationChanged;+ /// <summary>+ /// Gets the current path.+ /// </summary>+ private string CurrentPath => _navigationManager.ToAbsoluteUri(_navigationManager.Uri).GetLeftPart(UriPartial.Path);/// <summary>- /// Initializes a new instance of the <see cref="NavigationService"/> class.+ /// Redirect to the current page./// </summary>- /// <param name="navigationManager"></param>- public NavigationService(NavigationManager navigationManager)- {- _navigationManager = navigationManager;- _navigationManager.LocationChanged += (sender, args) =>- {- LocationChanged?.Invoke(sender, args);- };- }+ public void RedirectToCurrentPage() => RedirectTo(CurrentPath);/// <summary>/// Redirect to the specified URI.@@ -42,7 +59,7 @@ public class NavigationService/// <param name="forceLoad">Force load true/false.</param>public void RedirectTo(string? uri, bool forceLoad = false){- uri ??= "";+ uri ??= string.Empty;// Prevent open redirects.if (!System.Uri.IsWellFormedUriString(uri, UriKind.Relative))@@ -56,8 +73,8 @@ public class NavigationService/// <summary>/// Redirect to the specified URI with query parameters./// </summary>- /// <param name="uri"></param>- /// <param name="queryParameters"></param>+ /// <param name="uri">URI to redirect to.</param>+ /// <param name="queryParameters">Optional querystring parameters to add to the URL.</param>/// <param name="forceLoad">Force load true/false.</param>public void RedirectTo(string uri, Dictionary<string, object?> queryParameters, bool forceLoad = false){@@ -72,6 +89,7 @@ public class NavigationService/// </summary>/// <param name="uri">The URI with the query to modify.</param>/// <param name="parameters">The values to add, update, or remove.</param>+ /// <returns>The URI with the query modified.</returns>public string GetUriWithQueryParameters(string uri, IReadOnlyDictionary<string, object?> parameters) => _navigationManager.GetUriWithQueryParameters(uri, parameters);/// <summary>diff --git a/src/AliasVault.Admin/Services/UserService.cs b/src/AliasVault.Admin/Services/UserService.csindex 3ab2c72e6..daae5c732 100644--- a/src/AliasVault.Admin/Services/UserService.cs+++ b/src/AliasVault.Admin/Services/UserService.cs@@ -1,7 +1,13 @@+//-----------------------------------------------------------------------+// <copyright file="UserService.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasVault.Admin.Services;using System.ComponentModel.DataAnnotations;-using System.Security.Claims;using AliasServerDb;using Microsoft.AspNetCore.Identity;using Microsoft.EntityFrameworkCore;@@ -9,22 +15,16 @@ using Microsoft.EntityFrameworkCore;/// <summary>/// User service for managing users./// </summary>-public class UserService+/// <param name="dbContext">AliasServerDbContext instance.</param>+/// <param name="userManager">UserManager instance.</param>+/// <param name="httpContextAccessor">HttpContextManager instance.</param>+public class UserService(AliasServerDbContext dbContext, UserManager<AdminUser> userManager, IHttpContextAccessor httpContextAccessor){- private readonly AliasServerDbContext _dbContext;- private readonly UserManager<AdminUser> _userManager;- private readonly SignInManager<AdminUser> _signInManager;- private AdminUser? _user;- private readonly IHttpContextAccessor _httpContextAccessor;private const string AdminRole = "Admin";+ private AdminUser? _user;/// <summary>- /// Allow other components to subscribe to changes in the event object.- /// </summary>- public event Action OnChange = () => { };-- /// <summary>- /// The roles of the current user+ /// The roles of the current user./// </summary>private IList<string> _userRoles = new List<string>();@@ -34,26 +34,14 @@ public class UserServiceprivate bool _isAdmin;/// <summary>- /// Gets a value indicating whether the User is loaded and available, false if not. Use this before accessing User() method.+ /// Allow other components to subscribe to changes in the event object./// </summary>- public bool UserLoaded => _user != null;-- private void NotifyStateChanged() => OnChange.Invoke();+ public event Action OnChange = () => { };/// <summary>- /// Initializes a new instance of the <see cref="UserService"/> class.+ /// Gets a value indicating whether the User is loaded and available, false if not. Use this before accessing User() method./// </summary>- /// <param name="dbContext">AliasServerDbContext instance.</param>- /// <param name="userManager">UserManager instance.</param>- /// <param name="signInManager">SignInManager instance.</param>- /// <param name="httpContextAccessor">HttpContextManager instance.</param>- public UserService(AliasServerDbContext dbContext, UserManager<AdminUser> userManager, SignInManager<AdminUser> signInManager, IHttpContextAccessor httpContextAccessor)- {- _dbContext = dbContext;- _userManager = userManager;- _signInManager = signInManager;- _httpContextAccessor = httpContextAccessor;- }+ public bool UserLoaded => _user != null;/// <summary>/// Returns all users.@@ -61,19 +49,19 @@ public class UserService/// <returns>List of users.</returns>public async Task<List<AdminUser>> GetAllUsersAsync(){- var userList = await _userManager.Users.ToListAsync();+ var userList = await userManager.Users.ToListAsync();return userList;}/// <summary>- /// Finds and returns user by id, using the _userManager instead of the _dbContext.+ /// Finds and returns user by id, using the userManager instead of the dbContext./// This is necessary when performing actions on the user, such as changing password or deleting the object./// </summary>/// <param name="userId">User ID.</param>/// <returns>AdminUser object.</returns>public async Task<AdminUser> GetUserByIdUserManagerAsync(Guid userId){- var user = await _userManager.FindByIdAsync(userId.ToString());+ var user = await userManager.FindByIdAsync(userId.ToString());if (user == null){throw new Exception($"User with id {userId} not found.");@@ -85,7 +73,7 @@ public class UserService/// <summary>/// Returns inner User EF object./// </summary>- /// <returns></returns>+ /// <returns>User object.</returns>public AdminUser User(){if (_user == null)@@ -111,18 +99,18 @@ public class UserService/// <returns>Async task.</returns>public async Task LoadCurrentUserAsync(){- if (_httpContextAccessor.HttpContext != null)+ if (httpContextAccessor.HttpContext != null){// Load user from database. Use a new context everytime to ensure we get the latest data.- var userName = _httpContextAccessor.HttpContext?.User?.Identity?.Name ?? string.Empty;+ var userName = httpContextAccessor.HttpContext?.User?.Identity?.Name ?? string.Empty;- var user = await _dbContext.AdminUsers.FirstOrDefaultAsync(u => u.UserName == userName);+ var user = await dbContext.AdminUsers.FirstOrDefaultAsync(u => u.UserName == userName);if (user != null){_user = user;// Load all roles for current user.- _userRoles = await _userManager.GetRolesAsync(User());+ _userRoles = await userManager.GetRolesAsync(User());// Define if current user is admin._isAdmin = _userRoles.Contains(AdminRole);@@ -139,7 +127,7 @@ public class UserService/// <returns>List of roles.</returns>public async Task<List<string>> GetCurrentUserRolesAsync(){- var roles = await _userManager.GetRolesAsync(User());+ var roles = await userManager.GetRolesAsync(User());return roles.ToList();}@@ -151,7 +139,7 @@ public class UserService/// <returns>List of users matching the search term.</returns>public async Task<List<AdminUser>> SearchUsersAsync(string searchTerm){- return await _userManager.Users.Where(x => x.UserName != null && x.UserName.Contains(searchTerm)).Take(5).ToListAsync();+ return await userManager.Users.Where(x => x.UserName != null && x.UserName.Contains(searchTerm)).Take(5).ToListAsync();}/// <summary>@@ -169,7 +157,7 @@ public class UserServicereturn errors;}- var result = await _userManager.CreateAsync(user, password);+ var result = await userManager.CreateAsync(user, password);if (!result.Succeeded){foreach (var error in result.Errors)@@ -202,28 +190,30 @@ public class UserService// Update password if necessaryif (!string.IsNullOrEmpty(newPassword)){- var passwordRemoveResult = await _userManager.RemovePasswordAsync(user);+ var passwordRemoveResult = await userManager.RemovePasswordAsync(user);if (!passwordRemoveResult.Succeeded){foreach (var error in passwordRemoveResult.Errors){errors.Add(error.Description);}+return errors;}- var passwordAddResult = await _userManager.AddPasswordAsync(user, newPassword);+ var passwordAddResult = await userManager.AddPasswordAsync(user, newPassword);if (!passwordAddResult.Succeeded){foreach (var error in passwordAddResult.Errors){errors.Add(error.Description);}+return errors;}}- var result = await _userManager.UpdateAsync(user);+ var result = await userManager.UpdateAsync(user);if (!result.Succeeded){foreach (var error in result.Errors)@@ -247,7 +237,7 @@ public class UserService{List<string> errors = new();- var currentRoles = await _userManager.GetRolesAsync(user);+ var currentRoles = await userManager.GetRolesAsync(user);if (user.Id == User().Id && currentRoles.Contains(AdminRole) && !roles.Contains(AdminRole)){errors.Add("You cannot remove the Admin role from yourself if you are an Admin.");@@ -257,12 +247,28 @@ public class UserServicevar rolesToAdd = roles.Except(currentRoles).ToList();var rolesToRemove = currentRoles.Except(roles).ToList();- await _userManager.AddToRolesAsync(user, rolesToAdd);- await _userManager.RemoveFromRolesAsync(user, rolesToRemove);+ await userManager.AddToRolesAsync(user, rolesToAdd);+ await userManager.RemoveFromRolesAsync(user, rolesToRemove);return errors;}+ /// <summary>+ /// Checks if supplied password is correct for the user.+ /// </summary>+ /// <param name="user">User object.</param>+ /// <param name="password">The password to check.</param>+ /// <returns>Boolean indicating whether supplied password is valid and matches what is stored in the database..</returns>+ public async Task<bool> CheckPasswordAsync(AdminUser user, string password)+ {+ if (password.Length == 0)+ {+ return false;+ }++ return await userManager.CheckPasswordAsync(user, password);+ }+/// <summary>/// Validate if user object contents conform to the requirements./// </summary>@@ -291,7 +297,7 @@ public class UserServiceif (isUpdate){- var originalUser = await _userManager.FindByIdAsync(user.Id);+ var originalUser = await userManager.FindByIdAsync(user.Id);if (originalUser != null && user.UserName != originalUser.UserName){errors.Add("Username cannot be changed for existing users.");@@ -299,13 +305,13 @@ public class UserService}else{- var existingUser = await _userManager.FindByNameAsync(user.UserName);+ var existingUser = await userManager.FindByNameAsync(user.UserName);if (existingUser != null){errors.Add("Username is already in use.");}- var existingEmail = await _userManager.FindByEmailAsync(user.Email);+ var existingEmail = await userManager.FindByEmailAsync(user.Email);if (existingEmail != null){errors.Add("Email is already in use.");@@ -320,45 +326,5 @@ public class UserServicereturn errors;}- public async Task<List<string>> DeleteUserAsync(AdminUser user, bool forceDelete = false)- {- var errors = new List<string>();-- // Disallow deleting yourself, except when forceDelete is true- if (user.Id == User().Id && !forceDelete)- {- errors.Add("You cannot delete yourself.");- return errors;- }-- // First delete all related data...- // @TODO: do we not want to preserve certain anonymized data?--- // ...then delete the user- var result = await _userManager.DeleteAsync(user);- if (!result.Succeeded)- {- // Handle error, e.g. show error messages- errors.Add("Unable to delete user.");- }-- return errors;- }-- /// <summary>- /// Checks if supplied password is correct for the user.- /// </summary>- /// <param name="user">User object.</param>- /// <param name="password">The password to check.</param>- /// <returns>Boolean indicating whether supplied password is valid and matches what is stored in the database..</returns>- public async Task<bool> CheckPasswordAsync(AdminUser user, string password)- {- if (password.Length == 0)- {- return false;- }-- return await _userManager.CheckPasswordAsync(user, password);- }+ private void NotifyStateChanged() => OnChange.Invoke();}diff --git a/src/AliasVault.Admin/StartupTasks.cs b/src/AliasVault.Admin/StartupTasks.csindex db66fb469..a8be8af14 100644--- a/src/AliasVault.Admin/StartupTasks.cs+++ b/src/AliasVault.Admin/StartupTasks.cs@@ -1,3 +1,10 @@+//-----------------------------------------------------------------------+// <copyright file="StartupTasks.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasVault.Admin;using AliasServerDb;@@ -28,7 +35,7 @@ public static class StartupTasks/// <summary>/// Creates the admin user if it does not exist./// </summary>- /// <param name="serviceProvider"></param>+ /// <param name="serviceProvider">IServiceProvider instance.</param>/// <returns>Async Task.</returns>public static async Task SetAdminUser(IServiceProvider serviceProvider){diff --git a/src/AliasVault.Admin/wwwroot/css/tailwind.css b/src/AliasVault.Admin/wwwroot/css/tailwind.cssindex 73c40f226..956a04701 100644--- a/src/AliasVault.Admin/wwwroot/css/tailwind.css+++ b/src/AliasVault.Admin/wwwroot/css/tailwind.css@@ -1098,6 +1098,11 @@ video {background-color: rgb(253 222 133 / var(--tw-bg-opacity));}+.bg-primary-200 {+ --tw-bg-opacity: 1;+ background-color: rgb(251 203 116 / var(--tw-bg-opacity));+}+.bg-primary-600 {--tw-bg-opacity: 1;background-color: rgb(214 131 56 / var(--tw-bg-opacity));diff --git a/src/AliasVault.Client/Main/Components/Attachments/AttachmentUploader.razor b/src/AliasVault.Client/Main/Components/Attachments/AttachmentUploader.razorindex 3236271a3..42d50f7f2 100644--- a/src/AliasVault.Client/Main/Components/Attachments/AttachmentUploader.razor+++ b/src/AliasVault.Client/Main/Components/Attachments/AttachmentUploader.razor@@ -34,9 +34,15 @@</div>@code {+ /// <summary>+ /// Attachments to be uploaded.+ /// </summary>[Parameter]- public List<Attachment> Attachments { get; set; } = new List<Attachment>();+ public List<Attachment> Attachments { get; set; } = [];+ /// <summary>+ /// Callback that is invoked when the attachments are changed.+ /// </summary>[Parameter]public EventCallback<List<Attachment>> AttachmentsChanged { get; set; }diff --git a/src/AliasVault.Client/Main/Components/Attachments/AttachmentViewer.razor b/src/AliasVault.Client/Main/Components/Attachments/AttachmentViewer.razorindex 609d7ccef..467c2cab5 100644--- a/src/AliasVault.Client/Main/Components/Attachments/AttachmentViewer.razor+++ b/src/AliasVault.Client/Main/Components/Attachments/AttachmentViewer.razor@@ -35,6 +35,9 @@</div>@code {+ /// <summary>+ /// The attachments to display.+ /// </summary>[Parameter]public ICollection<Attachment> Attachments { get; set; } = new List<Attachment>();diff --git a/src/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor b/src/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razorindex 89721349f..d14cea7ea 100644--- a/src/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor+++ b/src/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor@@ -1,7 +1,4 @@-@using AliasVault.Client.Services--<!-- CopyPasteFormRow.razor -->-@inject ClipboardCopyService ClipboardCopyService+@inject ClipboardCopyService ClipboardCopyService@inject IJSRuntime JsRuntime@implements IDisposable@@ -17,12 +14,22 @@</div>@code {- [Parameter] public string Label { get; set; } = "Value";- [Parameter] public string Value { get; set; } = string.Empty;+ /// <summary>+ /// The label for the input.+ /// </summary>+ [Parameter]+ public string Label { get; set; } = "Value";++ /// <summary>+ /// The value to copy to the clipboard.+ /// </summary>+ [Parameter]+ public string Value { get; set; } = string.Empty;private bool _copied => ClipboardCopyService.GetCopiedId() == _inputId;private readonly string _inputId = Guid.NewGuid().ToString();+ /// <inheritdoc />protected override void OnInitialized(){ClipboardCopyService.OnCopy += HandleCopy;@@ -46,6 +53,7 @@StateHasChanged();}+ /// <inheritdoc />public void Dispose(){ClipboardCopyService.OnCopy -= HandleCopy;diff --git a/src/AliasVault.Client/Main/Components/Layout/LayoutPageTitle.razor b/src/AliasVault.Client/Main/Components/Layout/LayoutPageTitle.razorindex 937a500f6..2b7652f24 100644--- a/src/AliasVault.Client/Main/Components/Layout/LayoutPageTitle.razor+++ b/src/AliasVault.Client/Main/Components/Layout/LayoutPageTitle.razor@@ -1,6 +1,9 @@<PageTitle>@ChildContent - AliasVault</PageTitle>@code {+ /// <summary>+ /// The content to display as prefix in the page title.+ /// </summary>[Parameter]public RenderFragment ChildContent { get; set; } = default!;}diff --git a/src/AliasVault.Client/Main/Pages/Credentials/AddEdit.razor b/src/AliasVault.Client/Main/Pages/Credentials/AddEdit.razorindex 2439ad2c8..d2e7b4987 100644--- a/src/AliasVault.Client/Main/Pages/Credentials/AddEdit.razor+++ b/src/AliasVault.Client/Main/Pages/Credentials/AddEdit.razor@@ -3,7 +3,7 @@@inherits MainBase@inject CredentialService CredentialService@using System.Globalization-@using AliasGenerators.Implementations+@using AliasGenerators.Password@using AliasGenerators.Password.Implementations@if (EditMode)diff --git a/src/AliasVault.Client/Main/Pages/Sync/Sync.razor b/src/AliasVault.Client/Main/Pages/Sync/Sync.razorindex 32633e3bb..1a449a35f 100644--- a/src/AliasVault.Client/Main/Pages/Sync/Sync.razor+++ b/src/AliasVault.Client/Main/Pages/Sync/Sync.razor@@ -38,6 +38,7 @@private DbServiceState.DatabaseState CurrentDbState { get; set; } = new();private const int MinimumLoadingTimeMs = 800;+ /// <inheritdoc />protected override async Task OnInitializedAsync(){await base.OnInitializedAsync();@@ -118,6 +119,7 @@}}+ /// <inheritdoc />public void Dispose(){DbService.GetState().StateChanged -= OnDatabaseStateChanged;