Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace AndreGoepel.Marten.Identity.Blazor.Components.Account;

public static class IdentityComponentsEndpointRouteBuilderExtensions
{
// These endpoints are required by the Identity Razor components defined in the /Components/Account/Pages directory of this project.
public static IEndpointConventionBuilder MapAdditionalIdentityEndpoints(
this IEndpointRouteBuilder endpoints
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace AndreGoepel.Marten.Identity.Blazor.Components.Account;

// This is a server-side AuthenticationStateProvider that revalidates the security stamp for the connected user
// every 30 minutes an interactive circuit is connected.
internal sealed class IdentityRevalidatingAuthenticationStateProvider(
ILoggerFactory loggerFactory,
IServiceScopeFactory scopeFactory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@page "/Account/AccessDenied"
@attribute [AllowAnonymous]
@inherits IdentityLocalizedComponentBase

@inject NavigationManager NavigationManager

<AppPageTitle Title="@T("AccessDenied.PageTitle")" />

@code {
protected override void OnInitialized()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
string.IsNullOrWhiteSpace(model.NewPassword) ||
string.IsNullOrWhiteSpace(model.ConfirmPassword))
{
return; // Validatoren sollten das bereits abfangen
return; // Validators should already catch this
}

if (model.NewPassword != model.ConfirmPassword)
Expand All @@ -95,7 +95,6 @@
}

_isProcessing = true;
StateHasChanged();

try
{
Expand All @@ -115,7 +114,6 @@
);

Model = new();
StateHasChanged();
}
else
{
Expand All @@ -139,14 +137,10 @@
finally
{
_isProcessing = false;
StateHasChanged();
}
}

// Validation lives in the markup as Radzen validator components. RadzenTemplateForm
// (wrapped by CardForm) does not evaluate DataAnnotations and no DataAnnotationsValidator
// is present, so attributes here would never run — they were removed rather than
// translated into a second, silently-dead set of messages (#114).
// Validation lives in the markup as Radzen validators — RadzenTemplateForm/CardForm don't run DataAnnotations (#114).
private sealed class ChangePasswordModel
{
[DataType(DataType.Password)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<RadzenCard>
<RadzenStack Orientation="Orientation.Vertical" Gap="2rem" AlignItems="AlignItems.Stretch">

<!-- Starke Warnung -->
<RadzenAlert AlertStyle="AlertStyle.Danger"
AllowClose="false"
Icon="warning"
Expand Down Expand Up @@ -96,7 +95,6 @@
return;
}

// Zweifache Absicherung über Dialog
var confirm = await Confirm.ConfirmAsync(
T("DeletePersonalData.ConfirmMessage"),
T("DeletePersonalData.ConfirmTitle"),
Expand All @@ -114,7 +112,6 @@

try
{
// Passwort prüfen
if (!await UserManager.CheckPasswordAsync(_currentUser, model.Password))
{
NotificationService.Notify(NotificationSeverity.Error, T("DeletePersonalData.ErrorTitle"), T("DeletePersonalData.WrongPasswordDetail"));
Expand Down Expand Up @@ -149,14 +146,10 @@
finally
{
_isDeleting = false;
StateHasChanged();
}
}

// Validation lives in the markup as Radzen validator components. RadzenTemplateForm
// (wrapped by CardForm) does not evaluate DataAnnotations and no DataAnnotationsValidator
// is present, so attributes here would never run — they were removed rather than
// translated into a second, silently-dead set of messages (#114).
// Validation lives in the markup as Radzen validators — RadzenTemplateForm/CardForm don't run DataAnnotations (#114).
private sealed class InputModel
{
[DataType(DataType.Password)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
private async Task OnSubmitAsync()
{
_isProcessing = true;
StateHasChanged();

try
{
Expand All @@ -79,7 +78,17 @@

if (!result.Succeeded)
{
throw new InvalidOperationException("Failed to disable 2FA: " + string.Join(", ", result.Errors.Select(e => e.Description)));
Logger.LogError(
"Failed to disable 2FA for user {UserId}: {Errors}",
_user.Id,
string.Join(", ", result.Errors.Select(e => e.Description))
);
NotificationService.Notify(
NotificationSeverity.Error,
summary: T("Disable2fa.ErrorTitle"),
detail: T("Disable2fa.DisableFailedDetail")
);
return;
}

var userId = await UserManager.GetUserIdAsync(_user);
Expand All @@ -91,7 +100,7 @@
}
catch (Exception ex)
{
Logger.LogError(ex, "Failed to disable 2FA for user {UserId}", _user?.Id);
Logger.LogError(ex, "Unexpected error while disabling 2FA for user {UserId}", _user?.Id);
NotificationService.Notify(
NotificationSeverity.Error,
summary: T("Disable2fa.ErrorTitle"),
Expand All @@ -101,7 +110,6 @@
finally
{
_isProcessing = false;
StateHasChanged();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
}

_isChangingEmail = true;
StateHasChanged();

try
{
Expand All @@ -132,9 +131,6 @@
T("Email.SuccessTitle"),
T("Email.ConfirmationSentDetail")
);

// Optional: zurück zur Profile-Seite
// NavigationManager.NavigateTo("/Account/Manage/Profile");
}
catch (Exception)
{
Expand All @@ -147,7 +143,6 @@
finally
{
_isChangingEmail = false;
StateHasChanged();
}
}

Expand All @@ -157,7 +152,6 @@
return;

_isSendingVerification = true;
StateHasChanged();

try
{
Expand Down Expand Up @@ -195,14 +189,10 @@
finally
{
_isSendingVerification = false;
StateHasChanged();
}
}

// Validation lives in the markup as Radzen validator components. RadzenTemplateForm
// (wrapped by CardForm) does not evaluate DataAnnotations and no DataAnnotationsValidator
// is present, so attributes here would never run — they were removed rather than
// translated into a second, silently-dead set of messages (#114).
// Validation lives in the markup as Radzen validators — RadzenTemplateForm/CardForm don't run DataAnnotations (#114).
private sealed class ChangeEmailModel
{
public string? NewEmail { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ else
return;
}

// Strip spaces and hyphens
var verificationCode = model.Code?.Replace(" ", string.Empty).Replace("-", string.Empty) ?? "";

var is2FaTokenValid = await UserManager.VerifyTwoFactorTokenAsync(
Expand Down Expand Up @@ -151,7 +150,6 @@ else

private async ValueTask LoadSharedKeyAndQrCodeUriAsync(User user)
{
// Load the authenticator key & QR code URI to display on the form
var unformattedKey = await UserManager.GetAuthenticatorKeyAsync(user);
if (string.IsNullOrEmpty(unformattedKey))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
protected override async Task OnInitializedAsync()
{
_isLoading = true;
StateHasChanged();

try
{
Expand All @@ -128,7 +127,6 @@
finally
{
_isLoading = false;
StateHasChanged();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
<RadzenCard>
<RadzenStack Orientation="Orientation.Vertical" Gap="2rem" AlignItems="AlignItems.Stretch">

<!-- Erklärungstext -->
<RadzenText TextStyle="TextStyle.Body1">
@T("PersonalData.IntroText")
</RadzenText>

<!-- Warnhinweis -->
<RadzenAlert AlertStyle="AlertStyle.Danger"
AllowClose="false"
Icon="warning">
Expand All @@ -35,7 +33,6 @@
</RadzenAlert>

<div class="ag-card-actions ag-start">
<!-- Download (POST form) -->
<form action="/Account/Manage/DownloadPersonalData" method="post">
<AntiforgeryToken />
<RadzenButton ButtonType="ButtonType.Submit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
}

_isSaving = true;
StateHasChanged();

try
{
Expand Down Expand Up @@ -119,14 +118,10 @@
finally
{
_isSaving = false;
StateHasChanged();
}
}

// Validation lives in the markup as Radzen validator components. RadzenTemplateForm
// (wrapped by CardForm) does not evaluate DataAnnotations and no DataAnnotationsValidator
// is present, so attributes here would never run — they were removed rather than
// translated into a second, silently-dead set of messages (#114).
// Validation lives in the markup as Radzen validators — RadzenTemplateForm/CardForm don't run DataAnnotations (#114).
private sealed class ProfileModel
{
// UserName is rendered read-only, so it cannot be emptied from the UI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
}

_isSaving = true;
StateHasChanged();

try
{
Expand Down Expand Up @@ -168,14 +167,10 @@
finally
{
_isSaving = false;
StateHasChanged();
}
}

// Validation lives in the markup as Radzen validator components. RadzenTemplateForm
// (wrapped by CardForm) does not evaluate DataAnnotations and no DataAnnotationsValidator
// is present, so attributes here would never run — they were removed rather than
// translated into a second, silently-dead set of messages (#114).
// Validation lives in the markup as Radzen validators — RadzenTemplateForm/CardForm don't run DataAnnotations (#114).
private sealed class RenamePasskeyModel
{
public string Name { get; set; } = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<RadzenCard>
<RadzenStack Orientation="Orientation.Vertical" Gap="2rem" AlignItems="AlignItems.Stretch">

<!-- Warning (prominent, danger style) -->
<RadzenAlert AlertStyle="AlertStyle.Danger" Icon="warning" AllowClose="false">
<div class="font-medium">
@T("ResetAuthenticator.AlertLine1")
Expand All @@ -28,7 +27,6 @@
</div>
</RadzenAlert>

<!-- Action area -->
<RadzenStack Gap="1.5rem" AlignItems="AlignItems.Center">

<form method="post" action="/Account/Manage/ResetAuthenticator/ConfirmReset">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@

if (!result.Succeeded)
{
// Pre-existing bug fixed in passing: this joined the IdentityError objects
// themselves, not their Description — IdentityError doesn't override ToString(),
// so the notification showed the bare type name instead of the actual reason.
// No test covered the text, only that a notification fired, so it went unnoticed.
var reasons = string.Join(' ', result.Errors.Select(e => e.Description));
NotificationService.Notify(
NotificationSeverity.Error,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace AndreGoepel.Marten.Identity.Blazor.Components.Account;

public class PasskeyInputModel
public sealed class PasskeyInputModel
{
public string? CredentialJson { get; set; }
public string? Error { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
if (_module is null) return;

_isBusy = true;
StateHasChanged();

try
{
Expand All @@ -56,7 +55,6 @@
finally
{
_isBusy = false;
StateHasChanged();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@inject DialogService DialogService
@inject ConfirmService Confirm
@inject UserManager<User> UserManager
@inject UserStore<User> UserStore
@inject RoleManager<Role> RoleManager

<RadzenStack Gap="1rem" Orientation="Orientation.Vertical" JustifyContent="JustifyContent.SpaceBetween">
Expand Down Expand Up @@ -56,7 +57,7 @@
return;
}

var deleteResult = await UserManager.RemoveFromRoleAsync(user, _role.Name);
var deleteResult = await UserStore.RemoveFromRoleAsync(user, _role.Name, CancellationToken.None);
if (deleteResult.Succeeded)
{
_users = _users.Where(u => u.Id != user.Id).ToList();
Expand Down
Loading
Loading