Adds profile and settings pages

This commit is contained in:
2026-06-22 23:59:04 +02:00
parent 6976eb4337
commit 2544e20b3c
49 changed files with 2741 additions and 34 deletions
@@ -5,6 +5,8 @@ public record LoginRequest(string Email, string Password);
public record InviteUserRequest(string Email, string Role);
public record CompleteSetupRequest(string Token, string Password);
public record ChangeRoleRequest(string NewRole);
public record UpdateProfileRequest(string Name, string Email);
public record ChangePasswordRequest(string CurrentPassword, string NewPassword);
public record SetUserActiveRequest(bool IsActive);
public record PendingInvitationInfo(Guid Id, string Email, string Role, string Token, DateTimeOffset CreatedAt);
public record UserDto(
@@ -77,6 +77,19 @@ public class AuthService : IAuthService
}
}
public async Task ChangePasswordAsync(Guid userId, string currentPassword, string newPassword)
{
var user = await _userManager.FindByIdAsync(userId.ToString())
?? throw new UnauthorizedException("Gebruiker niet gevonden.");
var result = await _userManager.ChangePasswordAsync(user, currentPassword, newPassword);
if (!result.Succeeded)
{
var errors = string.Join(", ", result.Errors.Select(e => e.Description));
throw new ValidationException(errors);
}
}
private async Task<TokenResponse> GenerateTokenResponseAsync(ApplicationUser user)
{
var roles = await _userManager.GetRolesAsync(user);
@@ -21,4 +21,9 @@ public interface IAuthService
/// Trekt een refresh token in (uitloggen).
/// </summary>
Task RevokeTokenAsync(string refreshToken);
/// <summary>
/// Wijzigt het wachtwoord van de opgegeven gebruiker.
/// </summary>
Task ChangePasswordAsync(Guid userId, string currentPassword, string newPassword);
}