Adds profile and settings pages
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user