Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add add/edit page placeholder
Leendert de Borst3fb550d78170
diff --git a/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razor b/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razornew file mode 100644index 000000000..ae49ebcc6--- /dev/null+++ b/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razor@@ -0,0 +1,264 @@+@page "/add-alias"+@page "/alias/{id:guid}/edit"++@inject NavigationManager Navigation+@inherits PageBase+@using AliasDb+@using AliasGenerators.Identity+@using AliasGenerators.Identity.Implementations+@using AliasGenerators.Implementations+@using AliasGenerators.Password.Implementations++@if (EditMode)+{+ <LayoutPageTitle>Edit alias</LayoutPageTitle>+}+else {+ <LayoutPageTitle>Add alias</LayoutPageTitle>+}++<div class="grid grid-cols-1 px-4 pt-6 xl:grid-cols-3 xl:gap-4 dark:bg-gray-900">+ <div class="mb-4 col-span-full xl:mb-2">+ <Breadcrumb BreadcrumbItems="BreadcrumbItems" />+ <div class="flex items-center justify-between">+ <h1 class="text-xl font-semibold text-gray-900 sm:text-2xl dark:text-white">Add alias</h1>+ </div>+ <p>Create a new alias below.</p>+ </div>+</div>++@if (Loading)+{+ <LoadingIndicator />+}+else+{+ <div class="mb-6 bg-white shadow-md rounded-lg dark:bg-gray-800">+ <div class="px-4 py-2 bg-gray-200 dark:bg-gray-700">Service</div>+ <div class="p-4">+ <div class="mb-4">+ <label for="serviceName" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Service Name</label>+ <input type="text" id="serviceName" @bind="obj.Service.Name" required class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="serviceUrl" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Service URL</label>+ <input type="text" id="serviceUrl" @bind="obj.Service.Url" required class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ </div>+</div>++<div class="mb-6 bg-white shadow-md rounded-lg dark:bg-gray-800">+ <div class="px-4 py-2 bg-gray-200 dark:bg-gray-700">Identity</div>+ <div class="p-4">+ <div class="mb-4">+ <button class="px-4 py-2 text-white bg-blue-600 rounded-lg hover:bg-blue-700 focus:ring-4 focus:ring-blue-300 dark:bg-blue-500 dark:hover:bg-blue-600 dark:focus:ring-blue-800" @onclick="GenerateRandomIdentity">Generate Random Identity</button>+ </div>++ @if (IsIdentityLoading)+ {+ <p>Loading...</p>+ }++ <div class="mb-4">+ <label for="firstName" class="block text-sm font-medium text-gray-700 dark:text-gray-200">First Name</label>+ <input type="text" id="firstName" @bind="obj.Identity.FirstName" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="lastName" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Last Name</label>+ <input type="text" id="lastName" @bind="obj.Identity.LastName" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="gender" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Gender</label>+ <input type="text" id="gender" @bind="obj.Identity.Gender" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="nickName" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Nick Name</label>+ <input type="text" id="nickName" @bind="obj.Identity.NickName" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="birthDate" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Birth Date</label>+ <input type="date" id="birthDate" @bind="obj.Identity.BirthDate" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="addressStreet" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Address Street</label>+ <input type="text" id="addressStreet" @bind="obj.Identity.AddressStreet" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="addressCity" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Address City</label>+ <input type="text" id="addressCity" @bind="obj.Identity.AddressCity" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="addressState" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Address State</label>+ <input type="text" id="addressState" @bind="obj.Identity.AddressState" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="addressZipCode" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Address Zip Code</label>+ <input type="text" id="addressZipCode" @bind="obj.Identity.AddressZipCode" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="addressCountry" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Address Country</label>+ <input type="text" id="addressCountry" @bind="obj.Identity.AddressCountry" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="hobbies" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Hobbies</label>+ <input type="text" id="hobbies" @bind="obj.Identity.Hobbies" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="phoneMobile" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Phone Mobile</label>+ <input type="text" id="phoneMobile" @bind="obj.Identity.PhoneMobile" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ <div class="mb-4">+ <label for="bankAccountIBAN" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Bank Account IBAN</label>+ <input type="text" id="bankAccountIBAN" @bind="obj.Identity.BankAccountIBAN" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ </div>+</div>++<div class="mb-6 bg-white shadow-md rounded-lg dark:bg-gray-800">+ <div class="px-4 py-2 bg-gray-200 dark:bg-gray-700">Email</div>+ <div class="p-4">+ <div class="mb-4">+ <div class="relative flex items-center">+ <input type="text" @bind="obj.Identity.EmailPrefix" placeholder="Email prefix" aria-label="Email prefix" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ <span class="ml-2 text-gray-500 dark:text-gray-400">@@landmail.nl</span>+ </div>+ </div>+ </div>+</div>++<div class="mb-6 bg-white shadow-md rounded-lg dark:bg-gray-800">+ <div class="px-4 py-2 bg-gray-200 dark:bg-gray-700">Password</div>+ <div class="p-4">+ <div class="mb-4">+ <button class="px-4 py-2 text-white bg-secondary-600 rounded-lg hover:bg-secondary-700 focus:ring-4 focus:ring-secondary-300 dark:bg-secondary-500 dark:hover:bg-secondary-600 dark:focus:ring-secondary-800" @onclick="GenerateRandomPassword">Generate Random Password</button>+ </div>+ <div class="mb-4">+ <label for="passwordValue" class="block text-sm font-medium text-gray-700 dark:text-gray-200">Password</label>+ <input type="text" id="passwordValue" @bind="obj.Passwords.First().Value" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring focus:ring-primary-500 focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">+ </div>+ </div>+</div>++@if (IsSaving)+{+ <p>Saving...</p>+}++<button class="px-4 py-2 text-white bg-green-600 rounded-lg hover:bg-green-700 focus:ring-4 focus:ring-green-300 dark:bg-green-500 dark:hover:bg-green-600 dark:focus:ring-green-800" @onclick="SaveLogin">Save Aliases</button>+}++@code {+ [Parameter]+ public Guid? Id { get; set; }++ private bool EditMode = false;+ private bool Loading = true;+ private Login obj = new Login();+ private Password Password { get; set; } = new Password();++ private bool IsIdentityLoading { get; set; }+ private bool IsSaving { get; set; }++ protected override void OnInitialized()+ {+ if (Id.HasValue)+ {+ // Edit mode+ EditMode = true;+ }+ else+ {+ // Add mode+ EditMode = false;+ }+ }++ protected override async Task OnInitializedAsync()+ {+ if (EditMode)+ {+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Edit alias" });+ }+ else+ {+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Add new alias" });+ }+ }++ protected override async Task OnAfterRenderAsync(bool firstRender)+ {+ if (firstRender)+ {+ if (EditMode)+ {+ // Load existing obj, retrieve from service+ //obj = await AliasService.LoadAliasAsync(Id.Value);+ }+ else+ {+ // Create new obj+ obj = new Login();+ obj.Identity = new Identity();+ obj.Service = new Service();+ obj.Passwords = new List<Password>();+ obj.Passwords.Add(new Password());+ }++ // Hide loading spinner+ Loading = false;+ // Force re-render invoke so the charts can be rendered+ StateHasChanged();++ }+ }++ private async Task GenerateRandomIdentity()+ {+ IsIdentityLoading = true;+ StateHasChanged();++ // Generate a random identity using the IIdentityGenerator implementation.+ IIdentityGenerator identityGenerator = new FigIdentityGenerator();+ var identity = await identityGenerator.GenerateRandomIdentityAsync();++ // Generate random values for the Identity properties+ obj.Identity.FirstName = identity.FirstName;+ obj.Identity.LastName = identity.LastName;+ obj.Identity.NickName = identity.NickName;+ obj.Identity.Gender = identity.Gender == 1 ? "Male" : "Female";+ obj.Identity.BirthDate = DateTime.Now.AddYears(-30);+ obj.Identity.AddressStreet = identity.Address.Street;+ obj.Identity.AddressCity = identity.Address.City;+ obj.Identity.AddressState = identity.Address.State;+ obj.Identity.AddressZipCode = identity.Address.ZipCode;+ obj.Identity.AddressCountry = identity.Address.Country;+ obj.Identity.Hobbies = identity.Hobbies.First();+ obj.Identity.EmailPrefix = identity.EmailPrefix;+ obj.Identity.PhoneMobile = identity.PhoneMobile;+ obj.Identity.BankAccountIBAN = identity.BankAccountIBAN;++ // Generate password+ GenerateRandomPassword();++ IsIdentityLoading = false;+ StateHasChanged();+ }++ private void GenerateRandomPassword()+ {+ // Generate a random password using a IPasswordGenerator implementation.+ IPasswordGenerator passwordGenerator = new SpamOkPasswordGenerator();+ obj.Passwords.First().Value = passwordGenerator.GenerateRandomPassword();+ }++ private async Task SaveLogin()+ {+ IsSaving = true;+ StateHasChanged();++ IsSaving = false;+ StateHasChanged();++ Navigation.NavigateTo("/alias/" + obj.Id);+ }+}diff --git a/src/AliasVault.WebApp/Pages/Home.razor b/src/AliasVault.WebApp/Pages/Home.razorindex efc1d11f9..fb59f522d 100644--- a/src/AliasVault.WebApp/Pages/Home.razor+++ b/src/AliasVault.WebApp/Pages/Home.razor@@ -10,23 +10,29 @@<div class="grid grid-cols-1 px-4 pt-6 xl:grid-cols-3 xl:gap-4 dark:bg-gray-900"><div class="mb-4 col-span-full xl:mb-2"><Breadcrumb BreadcrumbItems="BreadcrumbItems" />- <h1 class="text-xl font-semibold text-gray-900 sm:text-2xl dark:text-white">Aliases</h1>+ <div class="flex items-center justify-between">+ <h1 class="text-xl font-semibold text-gray-900 sm:text-2xl dark:text-white">Aliases</h1>+ <a href="/add-alias" class="px-4 py-2 text-white bg-primary-600 rounded-lg hover:bg-primary-700 focus:ring-4 focus:ring-primary-300 dark:bg-primary-500 dark:hover:bg-primary-600 dark:focus:ring-primary-800">+ + Add new alias+ </a>+ </div><p>Find all of your aliases below.</p></div></div>@if (IsLoading){- <LoadingIndicator />+<LoadingIndicator />}<div class="grid gap-4 px-4 mb-4 md:grid-cols-4 xl:grid-cols-6">@foreach (var alias in Aliases){- <Alias Obj="@alias"/>+ <Alias Obj="@alias"/>}</div>+@code {private bool IsLoading { get; set; } = true;private List<Shared.Models.WebApi.AliasListEntry> Aliases { get; set; } = new();