Skip to content

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

Add notes and birthdate field, add date field validation (#58)

Leendert de Borsta644df1e3c2d
diff --git a/src/AliasVault.WebApp/Components/EditFormRow.razor b/src/AliasVault.WebApp/Components/EditFormRow.razor
index e790b18c7..42a5acb99 100644
--- a/src/AliasVault.WebApp/Components/EditFormRow.razor
+++ b/src/AliasVault.WebApp/Components/EditFormRow.razor
@@ -1,10 +1,16 @@
-@using AliasVault.WebApp.Services
-@inject ClipboardCopyService ClipboardCopyService
+@inject ClipboardCopyService ClipboardCopyService
@inject IJSRuntime JsRuntime
<label for="@Id" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Label</label>
<div class="relative">
- <input type="text" id="@Id" class="outline-0 shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg block w-full p-2.5 pr-10 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white" value="@Value" @oninput="OnInputChanged">
+ @if (Type == "textarea")
+ {
+ <textarea id="@Id" style="height: 200px;" class="outline-0 shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg block w-full p-2.5 pr-10 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white" value="@Value" @oninput="OnInputChanged"></textarea>
+ }
+ else
+ {
+ <input type="text" id="@Id" class="outline-0 shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg block w-full p-2.5 pr-10 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white" value="@Value" @oninput="OnInputChanged">
+ }
</div>
@code {
@@ -20,6 +26,12 @@
[Parameter]
public string Label { get; set; } = "Value";
+ /// <summary>
+ /// Type of input field.
+ /// </summary>
+ [Parameter]
+ public string Type { get; set; } = "text";
+
/// <summary>
/// Value of the input field.
/// </summary>
diff --git a/src/AliasVault.WebApp/Models/CredentialEdit.cs b/src/AliasVault.WebApp/Models/CredentialEdit.cs
index 5e19040e3..e99f50d20 100644
--- a/src/AliasVault.WebApp/Models/CredentialEdit.cs
+++ b/src/AliasVault.WebApp/Models/CredentialEdit.cs
@@ -9,6 +9,7 @@ namespace AliasVault.WebApp.Models;
using System.ComponentModel.DataAnnotations;
using AliasClientDb;
+using AliasVault.WebApp.Models.FormValidators;
/// <summary>
/// Credential edit model.
@@ -20,6 +21,11 @@ public class CredentialEdit
/// </summary>
public Guid Id { get; set; }
+ /// <summary>
+ /// Gets or sets notes field (free text input).
+ /// </summary>
+ public string Notes { get; set; } = null!;
+
/// <summary>
/// Gets or sets the name of the service.
/// </summary>
@@ -36,6 +42,12 @@ public class CredentialEdit
/// </summary>
public Alias Alias { get; set; } = null!;
+ /// <summary>
+ /// Gets or sets the Alias BirthDate.
+ /// </summary>
+ [StringDateFormat("yyyy-MM-dd")]
+ public string AliasBirthDate { get; set; } = null!;
+
/// <summary>
/// Gets or sets the Alias Password object.
/// </summary>
diff --git a/src/AliasVault.WebApp/Models/CredentialListEntry.cs b/src/AliasVault.WebApp/Models/CredentialListEntry.cs
index b43042428..0b3c46125 100644
--- a/src/AliasVault.WebApp/Models/CredentialListEntry.cs
+++ b/src/AliasVault.WebApp/Models/CredentialListEntry.cs
@@ -25,7 +25,7 @@ public class CredentialListEntry
/// <summary>
/// Gets or sets the alias service name.
/// </summary>
- public string Service { get; set; } = null!;
+ public string? Service { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the alias create date.
diff --git a/src/AliasVault.WebApp/Models/FormValidators/StringDateFormatAttribute.cs b/src/AliasVault.WebApp/Models/FormValidators/StringDateFormatAttribute.cs
new file mode 100644
index 000000000..2b8c68d46
--- /dev/null
+++ b/src/AliasVault.WebApp/Models/FormValidators/StringDateFormatAttribute.cs
@@ -0,0 +1,47 @@
+//-----------------------------------------------------------------------
+// <copyright file="StringDateFormatAttribute.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.WebApp.Models.FormValidators;
+
+using System.ComponentModel.DataAnnotations;
+using System.Globalization;
+
+/// <summary>
+/// Model validation attribute for date strings.
+/// </summary>
+public class StringDateFormatAttribute : ValidationAttribute
+{
+ private readonly string _format;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="StringDateFormatAttribute"/> class.
+ /// </summary>
+ /// <param name="format">The date format to validate.</param>
+ public StringDateFormatAttribute(string format)
+ {
+ _format = format;
+ }
+
+ /// <summary>
+ /// Check if the date string is in the correct format.
+ /// </summary>
+ /// <param name="value">The field value.</param>
+ /// <param name="validationContext">ValidationContext.</param>
+ /// <returns>ValidationResult.</returns>
+ protected override ValidationResult IsValid(object? value, ValidationContext validationContext)
+ {
+ if (value is string dateString)
+ {
+ if (DateTime.TryParseExact(dateString, _format, CultureInfo.InvariantCulture, DateTimeStyles.None, out _))
+ {
+ return ValidationResult.Success!;
+ }
+ }
+
+ return new ValidationResult($"The date must be in the format {_format}.", new List<string> { validationContext.MemberName! });
+ }
+}
diff --git a/src/AliasVault.WebApp/Pages/Credentials/AddEdit.razor b/src/AliasVault.WebApp/Pages/Credentials/AddEdit.razor
index aaf80ab91..583205d65 100644
--- a/src/AliasVault.WebApp/Pages/Credentials/AddEdit.razor
+++ b/src/AliasVault.WebApp/Pages/Credentials/AddEdit.razor
@@ -3,6 +3,7 @@
@inherits PageBase
@inject NavigationManager Navigation
@inject CredentialService CredentialService
+@using System.Globalization
@using AliasGenerators.Implementations
@using AliasGenerators.Password.Implementations
@using Alias = AliasClientDb.Alias
@@ -47,8 +48,8 @@ else
{
<EditForm Model="Obj" OnValidSubmit="SaveAlias">
<DataAnnotationsValidator />
- <div class="grid px-4 pt-6 lg:gap-4 dark:bg-gray-900">
- <div class="col">
+ <div class="grid grid-cols-3 px-4 pt-6 lg:gap-4 dark:bg-gray-900">
+ <div class="col-1">
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<h3 class="mb-4 text-xl font-semibold dark:text-white">Service</h3>
<div class="grid gap-6">
@@ -61,8 +62,19 @@ else
</div>
</div>
</div>
+
+ <div class="col">
+ <div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
+ <h3 class="mb-4 text-xl font-semibold dark:text-white">Notes</h3>
+ <div class="grid gap-6">
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Type="textarea" Id="first-name" Label="Notes" @bind-Value="Obj.Notes"></EditFormRow>
+ </div>
+ </div>
+ </div>
+ </div>
</div>
- <div class="col">
+ <div class="col col-span-2">
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<h3 class="mb-4 text-xl font-semibold dark:text-white">Login credentials</h3>
<div class="mb-4">
@@ -88,58 +100,61 @@ else
</div>
</div>
</div>
- </div>
- </div>
- <div class="grid px-4 pt-6 lg:gap-4 dark:bg-gray-900">
- <div class="col">
- <div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <h3 class="mb-4 text-xl font-semibold dark:text-white">Identity</h3>
- <div class="grid gap-6">
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="first-name" Label="First Name" @bind-Value="Obj.Alias.FirstName"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="last-name" Label="Last Name" @bind-Value="Obj.Alias.LastName"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="gender" Label="Gender" @bind-Value="Obj.Alias.Gender"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="nickname" Label="Nick Name" @bind-Value="Obj.Alias.NickName"></EditFormRow>
- </div>
- <!--<div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="birthdate" Label="Birth Date" @bind-Value="Obj.Alias.BirthDate"></EditFormRow>
- </div>
- -->
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="street" Label="Address Street" @bind-Value="Obj.Alias.AddressStreet"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="city" Label="Address City" @bind-Value="Obj.Alias.AddressCity"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="state" Label="Address State" @bind-Value="Obj.Alias.AddressState"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="zipcode" Label="Address Zip Code" @bind-Value="Obj.Alias.AddressZipCode"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="country" Label="Address Country" @bind-Value="Obj.Alias.AddressCountry"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="hobbies" Label="Hobbies" @bind-Value="Obj.Alias.Hobbies"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="phone-mobile" Label="Phone Mobile" @bind-Value="Obj.Alias.PhoneMobile"></EditFormRow>
- </div>
- <div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="iban" Label="Bank Account IBAN" @bind-Value="Obj.Alias.BankAccountIBAN"></EditFormRow>
+ <div class="col">
+ <div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
+ <h3 class="mb-4 text-xl font-semibold dark:text-white">Identity</h3>
+ <div class="grid gap-6">
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="first-name" Label="First Name" @bind-Value="Obj.Alias.FirstName"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="last-name" Label="Last Name" @bind-Value="Obj.Alias.LastName"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="gender" Label="Gender" @bind-Value="Obj.Alias.Gender"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="nickname" Label="Nick Name" @bind-Value="Obj.Alias.NickName"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="birthdate" Label="Birth Date" @bind-Value="Obj.AliasBirthDate"></EditFormRow>
+ <ValidationMessage For="() => Obj.AliasBirthDate"/>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="street" Label="Address Street" @bind-Value="Obj.Alias.AddressStreet"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="city" Label="Address City" @bind-Value="Obj.Alias.AddressCity"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="state" Label="Address State" @bind-Value="Obj.Alias.AddressState"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="zipcode" Label="Address Zip Code" @bind-Value="Obj.Alias.AddressZipCode"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="country" Label="Address Country" @bind-Value="Obj.Alias.AddressCountry"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="hobbies" Label="Hobbies" @bind-Value="Obj.Alias.Hobbies"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="phone-mobile" Label="Phone Mobile" @bind-Value="Obj.Alias.PhoneMobile"></EditFormRow>
+ </div>
+ <div class="col-span-6 sm:col-span-3">
+ <EditFormRow Id="iban" Label="Bank Account IBAN" @bind-Value="Obj.Alias.BankAccountIBAN"></EditFormRow>
+ </div>
</div>
</div>
+
+ <button type="submit" 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">Save Credentials</button>
</div>
</div>
- <button type="submit" 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">Save Credentials</button>
+ </div>
+
+ <div class="grid px-4 pt-6 lg:gap-4 dark:bg-gray-900">
+
</div>
</EditForm>
@@ -185,6 +200,7 @@ else
if (EditMode)
{
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "View credential", Url = $"/credentials/{Id}" });
BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Edit credential" });
}
else
@@ -333,6 +349,7 @@ else
return new CredentialEdit
{
Id = alias.Id,
+ Notes = alias.Notes ?? string.Empty,
ServiceName = alias.Service.Name ?? string.Empty,
ServiceUrl = alias.Service.Url,
Password = alias.Passwords.FirstOrDefault() ?? new Password
@@ -342,6 +359,7 @@ else
UpdatedAt = DateTime.UtcNow,
},
Alias = alias.Alias,
+ AliasBirthDate = alias.Alias.BirthDate.ToString("yyyy-MM-dd"),
CreateDate = alias.CreatedAt,
LastUpdate = alias.UpdatedAt
};
@@ -349,9 +367,10 @@ else
private Credential CredentialEditToCredential(CredentialEdit alias)
{
- return new Credential()
+ var credential = new Credential()
{
Id = alias.Id,
+ Notes = alias.Notes,
Service = new Service
{
Name = alias.ServiceName,
@@ -363,5 +382,16 @@ else
},
Alias = alias.Alias,
};
+
+ if (string.IsNullOrWhiteSpace(alias.AliasBirthDate))
+ {
+ credential.Alias.BirthDate = DateTime.MinValue;
+ }
+ else
+ {
+ credential.Alias.BirthDate = DateTime.Parse(alias.AliasBirthDate, new CultureInfo("en-US"));
+ }
+
+ return credential;
}
}
diff --git a/src/AliasVault.WebApp/Pages/Credentials/View.razor b/src/AliasVault.WebApp/Pages/Credentials/View.razor
index 5ed0309af..4c74aec74 100644
--- a/src/AliasVault.WebApp/Pages/Credentials/View.razor
+++ b/src/AliasVault.WebApp/Pages/Credentials/View.razor
@@ -11,7 +11,6 @@
}
else
{
-
<div class="grid grid-cols-2 px-4 pt-6 md:grid-cols-3 lg:gap-4 dark:bg-gray-900">
<div class="mb-4 col-span-full xl:mb-2">
<Breadcrumb BreadcrumbItems="BreadcrumbItems"/>
@@ -42,6 +41,13 @@ else
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<RecentEmails EmailPrefix="@Alias.Alias.EmailPrefix" />
</div>
+ @if (Alias.Notes != null && Alias.Notes.Length > 0)
+ {
+ <div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
+ <h3 class="mb-4 text-xl font-semibold dark:text-white">Notes</h3>
+ @Alias.Notes
+ </div>
+ }
</div>
<div class="col-span-2">
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
@@ -73,9 +79,9 @@ else
<div class="col-span-6 sm:col-span-3">
<CopyPasteFormRow Label="Last name" Value="@(Alias.Alias.LastName)"></CopyPasteFormRow>
</div>
- <!--<div class="col-span-6 sm:col-span-3">
- <CopyPasteFormRow Label="Birthdate" Value="@(Alias.Alias.BirthDate)"></CopyPasteFormRow>
- </div>-->
+ <div class="col-span-6 sm:col-span-3">
+ <CopyPasteFormRow Label="Birthdate" Value="@(Alias.Alias.BirthDate.ToString("yyyy-MM-dd"))"></CopyPasteFormRow>
+ </div>
</div>
</form>
</div>
diff --git a/src/AliasVault.WebApp/Pages/Home.razor b/src/AliasVault.WebApp/Pages/Home.razor
index 5b0d0fd99..26f330a4c 100644
--- a/src/AliasVault.WebApp/Pages/Home.razor
+++ b/src/AliasVault.WebApp/Pages/Home.razor
@@ -43,11 +43,11 @@
if (firstRender)
{
- await LoadAliasesAsync();
+ await LoadCredentialsAsync();
}
}
- private async Task LoadAliasesAsync()
+ private async Task LoadCredentialsAsync()
{
IsLoading = true;
StateHasChanged();
diff --git a/src/AliasVault.WebApp/Services/CredentialService.cs b/src/AliasVault.WebApp/Services/CredentialService.cs
index ae45fd14d..2a3d71abe 100644
--- a/src/AliasVault.WebApp/Services/CredentialService.cs
+++ b/src/AliasVault.WebApp/Services/CredentialService.cs
@@ -47,6 +47,7 @@ public class CredentialService(HttpClient httpClient, DbService dbService)
{
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow,
+ Notes = loginObject.Notes,
Username = loginObject.Alias.NickName ?? string.Empty, // TODO: refactor to have actual username in UI.
Alias = new AliasClientDb.Alias()
{
@@ -114,6 +115,7 @@ public class CredentialService(HttpClient httpClient, DbService dbService)
.FirstAsync();
login.UpdatedAt = DateTime.UtcNow;
+ login.Notes = loginObject.Notes;
login.Alias.NickName = loginObject.Alias.NickName;
login.Alias.FirstName = loginObject.Alias.FirstName;
login.Alias.LastName = loginObject.Alias.LastName;
@@ -177,7 +179,7 @@ public class CredentialService(HttpClient httpClient, DbService dbService)
{
Id = x.Id,
Logo = x.Service.Logo,
- Service = x.Service.Name ?? "n/a",
+ Service = x.Service.Name,
CreateDate = x.CreatedAt,
})
.ToListAsync();
diff --git a/src/AliasVault.WebApp/wwwroot/css/tailwind.css b/src/AliasVault.WebApp/wwwroot/css/tailwind.css
index c354fcb5f..a338b761c 100644
--- a/src/AliasVault.WebApp/wwwroot/css/tailwind.css
+++ b/src/AliasVault.WebApp/wwwroot/css/tailwind.css
@@ -570,10 +570,6 @@ video {
visibility: hidden;
}
-.collapse {
- visibility: collapse;
-}
-
.fixed {
position: fixed;
}
@@ -646,10 +642,6 @@ video {
margin-bottom: 1rem;
}
-.-mb-1 {
- margin-bottom: -0.25rem;
-}
-
.-ml-1 {
margin-left: -0.25rem;
}
@@ -682,10 +674,6 @@ video {
margin-left: 0.25rem;
}
-.ml-2 {
- margin-left: 0.5rem;
-}
-
.ml-3 {
margin-left: 0.75rem;
}
@@ -718,10 +706,6 @@ video {
margin-top: 0px;
}
-.mt-2 {
- margin-top: 0.5rem;
-}
-
.mt-4 {
margin-top: 1rem;
}
@@ -786,6 +770,10 @@ video {
height: 1.5rem;
}
+.h-7 {
+ height: 1.75rem;
+}
+
.h-8 {
height: 2rem;
}
@@ -798,10 +786,6 @@ video {
height: 100%;
}
-.h-7 {
- height: 1.75rem;
-}
-
.w-1\/2 {
width: 50%;
}
@@ -834,6 +818,10 @@ video {
width: 16rem;
}
+.w-7 {
+ width: 1.75rem;
+}
+
.w-8 {
width: 2rem;
}
@@ -842,10 +830,6 @@ video {
width: 100%;
}
-.w-7 {
- width: 1.75rem;
-}
-
.min-w-full {
min-width: 100%;
}
@@ -904,6 +888,10 @@ video {
grid-template-columns: repeat(7, minmax(0, 1fr));
}
+.grid-cols-3 {
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+}
+
.flex-col {
flex-direction: column;
}
@@ -1143,10 +1131,6 @@ video {
fill: #d68338;
}
-.fill-none {
- fill: none;
-}
-
.p-2 {
padding: 0.5rem;
}
@@ -1221,10 +1205,6 @@ video {
padding-right: 0.75rem;
}
-.ps-3 {
- padding-inline-start: 0.75rem;
-}
-
.pt-16 {
padding-top: 4rem;
}
@@ -1778,10 +1758,6 @@ video {
margin-bottom: 0px;
}
- .sm\:block {
- display: block;
- }
-
.sm\:flex {
display: flex;
}