Skip to content

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

Fix multiple attachment add bug (#81)

Leendert de Borst8d9c80ef617b
diff --git a/src/AliasVault.WebApp/Components/Attachments/AttachmentUploader.razor b/src/AliasVault.WebApp/Components/Attachments/AttachmentUploader.razor
index d0fc632c4..3236271a3 100644
--- a/src/AliasVault.WebApp/Components/Attachments/AttachmentUploader.razor
+++ b/src/AliasVault.WebApp/Components/Attachments/AttachmentUploader.razor
@@ -1,4 +1,5 @@
-@inject IJSRuntime JSRuntime
+@using System.IO
+@inject IJSRuntime JSRuntime
<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">
@@ -39,9 +40,6 @@
[Parameter]
public EventCallback<List<Attachment>> AttachmentsChanged { get; set; }
- [Parameter]
- public Guid CredentialId { get; set; }
-
private string statusMessage = string.Empty;
private async Task HandleFileSelection(InputFileChangeEventArgs e)
@@ -61,7 +59,7 @@
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow,
};
-
+
Attachments.Add(attachment);
await AttachmentsChanged.InvokeAsync(Attachments);
@@ -94,4 +92,4 @@
StateHasChanged();
}
-}
\ No newline at end of file
+}
diff --git a/src/AliasVault.WebApp/Components/Attachments/AttachmentViewer.razor b/src/AliasVault.WebApp/Components/Attachments/AttachmentViewer.razor
index 04c81966d..609d7ccef 100644
--- a/src/AliasVault.WebApp/Components/Attachments/AttachmentViewer.razor
+++ b/src/AliasVault.WebApp/Components/Attachments/AttachmentViewer.razor
@@ -10,7 +10,6 @@
<tr>
<th scope="col" class="px-6 py-3">Filename</th>
<th scope="col" class="px-6 py-3">Created At</th>
- <th scope="col" class="px-6 py-3">Actions</th>
</tr>
</thead>
<tbody>
@@ -18,14 +17,11 @@
{
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
- @attachment.Filename
+ <span @onclick="() => DownloadAttachment(attachment)" class="text-primary cursor-pointer">@attachment.Filename</span>
</td>
<td class="px-6 py-4">
@attachment.CreatedAt.ToLocalTime().ToString("g")
</td>
- <td class="px-6 py-4">
- <button @onclick="() => DownloadAttachment(attachment)" class="font-medium text-blue-600 dark:text-blue-500 hover:underline">Download</button>
- </td>
</tr>
}
</tbody>
@@ -62,4 +58,4 @@
await Console.Error.WriteLineAsync($"Error downloading attachment: {ex.Message}");
}
}
-}
\ No newline at end of file
+}
diff --git a/src/AliasVault.WebApp/Models/CredentialEdit.cs b/src/AliasVault.WebApp/Models/CredentialEdit.cs
index 06c15c4d4..2959db074 100644
--- a/src/AliasVault.WebApp/Models/CredentialEdit.cs
+++ b/src/AliasVault.WebApp/Models/CredentialEdit.cs
@@ -7,6 +7,8 @@
namespace AliasVault.WebApp.Models;
+using System;
+using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using AliasClientDb;
using AliasVault.WebApp.Models.FormValidators;
diff --git a/src/AliasVault.WebApp/Pages/Credentials/AddEdit.razor b/src/AliasVault.WebApp/Pages/Credentials/AddEdit.razor
index 5da9dfd34..c69299a49 100644
--- a/src/AliasVault.WebApp/Pages/Credentials/AddEdit.razor
+++ b/src/AliasVault.WebApp/Pages/Credentials/AddEdit.razor
@@ -81,10 +81,9 @@ else
<h3 class="mb-4 text-xl font-semibold dark:text-white">Attachments</h3>
<div class="grid gap-6">
<div class="col-span-6 sm:col-span-3">
- <AttachmentUploader
+ <AttachmentUploader
Attachments="@Obj.Attachments"
- AttachmentsChanged="@HandleAttachmentsChanged"
- CredentialId="@Obj.Id" />
+ AttachmentsChanged="@HandleAttachmentsChanged" />
</div>
</div>
</div>
@@ -291,7 +290,7 @@ else
Obj.Alias.LastName = identity.LastName;
Obj.Alias.NickName = identity.NickName;
Obj.Alias.Gender = identity.Gender == 1 ? "Male" : "Female";
- Obj.Alias.BirthDate = DateTime.Now.AddYears(-30);
+ Obj.AliasBirthDate = identity.BirthDate.ToString("yyyy-MM-dd");
Obj.Alias.AddressStreet = identity.Address.Street;
Obj.Alias.AddressCity = identity.Address.City;
Obj.Alias.AddressState = identity.Address.State;
diff --git a/src/AliasVault.WebApp/Services/CredentialService.cs b/src/AliasVault.WebApp/Services/CredentialService.cs
index 54db385da..886ae0482 100644
--- a/src/AliasVault.WebApp/Services/CredentialService.cs
+++ b/src/AliasVault.WebApp/Services/CredentialService.cs
@@ -7,7 +7,12 @@
namespace AliasVault.WebApp.Services;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
using System.Net.Http.Json;
+using System.Threading.Tasks;
using AliasClientDb;
using AliasVault.Shared.Models;
using AliasVault.WebApp.Models;
@@ -155,7 +160,7 @@ public class CredentialService(HttpClient httpClient, DbService dbService)
var existingAttachments = login.Attachments.ToList();
foreach (var existingAttachment in existingAttachments)
{
- if (!loginObject.Attachments.Any(a => a.Id == existingAttachment.Id))
+ if (!loginObject.Attachments.Any(a => a.Id != Guid.Empty && a.Id == existingAttachment.Id))
{
context.Entry(existingAttachment).State = EntityState.Deleted;
}
@@ -164,7 +169,7 @@ public class CredentialService(HttpClient httpClient, DbService dbService)
// Add new attachments
foreach (var attachment in loginObject.Attachments)
{
- if (!login.Attachments.Any(a => a.Id == attachment.Id))
+ if (!login.Attachments.Any(a => attachment.Id != Guid.Empty && a.Id == attachment.Id))
{
login.Attachments.Add(attachment);
}
diff --git a/src/AliasVault.WebApp/wwwroot/css/tailwind.css b/src/AliasVault.WebApp/wwwroot/css/tailwind.css
index b2389ab9d..9e5141b3a 100644
--- a/src/AliasVault.WebApp/wwwroot/css/tailwind.css
+++ b/src/AliasVault.WebApp/wwwroot/css/tailwind.css
@@ -884,14 +884,14 @@ video {
list-style-position: inside;
}
-.list-none {
- list-style-type: none;
-}
-
.list-disc {
list-style-type: disc;
}
+.list-none {
+ list-style-type: none;
+}
+
.grid-cols-1 {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
@@ -1220,16 +1220,16 @@ video {
padding-bottom: 0.75rem;
}
-.py-6 {
- padding-top: 1.5rem;
- padding-bottom: 1.5rem;
-}
-
.py-4 {
padding-top: 1rem;
padding-bottom: 1rem;
}
+.py-6 {
+ padding-top: 1.5rem;
+ padding-bottom: 1.5rem;
+}
+
.pr-10 {
padding-right: 2.5rem;
}
@@ -1272,6 +1272,11 @@ video {
line-height: 1.5rem;
}
+.text-lg {
+ font-size: 1.125rem;
+ line-height: 1.75rem;
+}
+
.text-sm {
font-size: 0.875rem;
line-height: 1.25rem;
@@ -1287,11 +1292,6 @@ video {
line-height: 1rem;
}
-.text-lg {
- font-size: 1.125rem;
- line-height: 1.75rem;
-}
-
.font-bold {
font-weight: 700;
}
@@ -1353,6 +1353,11 @@ video {
color: rgb(107 114 128 / var(--tw-text-opacity));
}
+.text-gray-600 {
+ --tw-text-opacity: 1;
+ color: rgb(75 85 99 / var(--tw-text-opacity));
+}
+
.text-gray-700 {
--tw-text-opacity: 1;
color: rgb(55 65 81 / var(--tw-text-opacity));
@@ -1383,6 +1388,11 @@ video {
color: rgb(184 112 47 / var(--tw-text-opacity));
}
+.text-red-500 {
+ --tw-text-opacity: 1;
+ color: rgb(239 68 68 / var(--tw-text-opacity));
+}
+
.text-red-800 {
--tw-text-opacity: 1;
color: rgb(153 27 27 / var(--tw-text-opacity));
@@ -1393,19 +1403,9 @@ video {
color: rgb(255 255 255 / var(--tw-text-opacity));
}
-.text-gray-600 {
- --tw-text-opacity: 1;
- color: rgb(75 85 99 / var(--tw-text-opacity));
-}
-
-.text-red-500 {
+.text-primary-900 {
--tw-text-opacity: 1;
- color: rgb(239 68 68 / var(--tw-text-opacity));
-}
-
-.text-blue-600 {
- --tw-text-opacity: 1;
- color: rgb(37 99 235 / var(--tw-text-opacity));
+ color: rgb(123 74 30 / var(--tw-text-opacity));
}
.opacity-0 {
@@ -1533,14 +1533,14 @@ video {
color: rgb(184 112 47 / var(--tw-text-opacity));
}
-.hover\:text-white:hover {
+.hover\:text-red-700:hover {
--tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity));
+ color: rgb(185 28 28 / var(--tw-text-opacity));
}
-.hover\:text-red-700:hover {
+.hover\:text-white:hover {
--tw-text-opacity: 1;
- color: rgb(185 28 28 / var(--tw-text-opacity));
+ color: rgb(255 255 255 / var(--tw-text-opacity));
}
.hover\:underline:hover {