Skip to content

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

Refresh password salt and ephemeral after changing it (#809)

Leendert de Borst3617c551e354
diff --git a/src/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor b/src/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor
index 185462f5b..e45082052 100644
--- a/src/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor
+++ b/src/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor
@@ -104,28 +104,37 @@ else
{
await base.OnAfterRenderAsync(firstRender);
- // Check on server if 2FA is enabled
+ // Get the current password ephemeral and salt from the server
+ // which is required to confirm the current password.
if (firstRender)
{
- // Get the QR code and secret for the authenticator app.
- var response = await Http.GetFromJsonAsync<PasswordChangeInitiateResponse>("v1/Auth/change-password/initiate");
+ await GetCurrentPasswordEphemeralAndSalt();
- if (response == null)
- {
- GlobalNotificationService.AddErrorMessage("Failed to initiate the password change process.", true);
- IsLoading = false;
- StateHasChanged();
- return;
- }
+ IsLoading = false;
+ StateHasChanged();
+ }
+ }
- CurrentServerEphemeral = response.ServerEphemeral;
- CurrentSalt = response.Salt;
- CurrentEncryptionType = response.EncryptionType;
- CurrentEncryptionSettings = response.EncryptionSettings;
+ /// <summary>
+ /// Gets the current password ephemeral and salt from the server which
+ /// is required to confirm the current password.
+ /// </summary>
+ private async Task GetCurrentPasswordEphemeralAndSalt()
+ {
+ var response = await Http.GetFromJsonAsync<PasswordChangeInitiateResponse>("v1/Auth/change-password/initiate");
+ if (response == null)
+ {
+ GlobalNotificationService.AddErrorMessage("Failed to initiate the password change process.", true);
IsLoading = false;
StateHasChanged();
+ return;
}
+
+ CurrentServerEphemeral = response.ServerEphemeral;
+ CurrentSalt = response.Salt;
+ CurrentEncryptionType = response.EncryptionType;
+ CurrentEncryptionSettings = response.EncryptionSettings;
}
/// <summary>
@@ -215,6 +224,10 @@ else
// Set success message.
GlobalNotificationService.AddSuccessMessage("Password changed successfully.", true);
+ // Get the new password ephemeral and salt from the server, which is required if the usre
+ // wants to change the password again.
+ await GetCurrentPasswordEphemeralAndSalt();
+
GlobalLoadingSpinner.Hide();
StateHasChanged();
}