Verrouille le nom d'utilisateur en edition admin
This commit is contained in:
@@ -2,8 +2,6 @@ namespace ChessCubing.App.Models.Users;
|
||||
|
||||
public sealed class AdminUpdateUserRequest
|
||||
{
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
public string? Email { get; set; }
|
||||
|
||||
public string? FirstName { get; set; }
|
||||
|
||||
@@ -308,7 +308,11 @@
|
||||
<div class="admin-form-grid admin-edit-form-grid">
|
||||
<label class="field">
|
||||
<span>Nom d'utilisateur</span>
|
||||
<InputText @bind-Value="EditFormModel.Username" />
|
||||
<InputText @bind-Value="EditFormModel.Username"
|
||||
readonly
|
||||
aria-readonly="true"
|
||||
title="Le nom d'utilisateur ne peut pas etre modifie."
|
||||
class="admin-readonly-field" />
|
||||
<ValidationMessage For="@(() => EditFormModel.Username)" />
|
||||
</label>
|
||||
|
||||
@@ -789,7 +793,6 @@
|
||||
{
|
||||
var payload = new AdminUpdateUserRequest
|
||||
{
|
||||
Username = EditFormModel.Username ?? string.Empty,
|
||||
Email = EditFormModel.Email,
|
||||
FirstName = EditFormModel.FirstName,
|
||||
LastName = EditFormModel.LastName,
|
||||
|
||||
@@ -70,8 +70,6 @@ public sealed class AdminUserDetailResponse
|
||||
|
||||
public sealed class AdminUpdateUserRequest
|
||||
{
|
||||
public string Username { get; init; } = string.Empty;
|
||||
|
||||
public string? Email { get; init; }
|
||||
|
||||
public string? FirstName { get; init; }
|
||||
|
||||
@@ -251,8 +251,9 @@ adminGroup.MapPut("/users/{subject}", async Task<IResult> (
|
||||
{
|
||||
try
|
||||
{
|
||||
var existingIdentity = await keycloak.GetAdminUserAsync(subject, cancellationToken);
|
||||
var normalized = NormalizeAdminUpdate(request);
|
||||
var fallbackDisplayName = BuildIdentityDisplayNameFromParts(normalized.FirstName, normalized.LastName, normalized.Username);
|
||||
var fallbackDisplayName = BuildIdentityDisplayNameFromParts(normalized.FirstName, normalized.LastName, existingIdentity.Username);
|
||||
var siteProfileRequest = new UpdateUserProfileRequest
|
||||
{
|
||||
DisplayName = request.DisplayName,
|
||||
@@ -268,7 +269,7 @@ adminGroup.MapPut("/users/{subject}", async Task<IResult> (
|
||||
var updatedIdentity = await keycloak.UpdateAdminUserAsync(
|
||||
subject,
|
||||
new AdminIdentityUserUpdateRequest(
|
||||
normalized.Username,
|
||||
existingIdentity.Username,
|
||||
normalized.Email,
|
||||
normalized.FirstName,
|
||||
normalized.LastName,
|
||||
@@ -421,13 +422,11 @@ static AdminUserDetailResponse MapAdminDetail(AdminIdentityUser identity, UserPr
|
||||
|
||||
static NormalizedAdminUserUpdate NormalizeAdminUpdate(AdminUpdateUserRequest request)
|
||||
{
|
||||
var username = NormalizeRequiredValue(request.Username, "nom d'utilisateur", 120);
|
||||
var email = NormalizeEmail(request.Email);
|
||||
var firstName = NormalizeOptionalValue(request.FirstName, "prenom", 120);
|
||||
var lastName = NormalizeOptionalValue(request.LastName, "nom", 120);
|
||||
|
||||
return new NormalizedAdminUserUpdate(
|
||||
username,
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
@@ -575,7 +574,6 @@ static async Task SignInAsync(HttpContext httpContext, KeycloakUserInfo userInfo
|
||||
}
|
||||
|
||||
sealed record NormalizedAdminUserUpdate(
|
||||
string Username,
|
||||
string? Email,
|
||||
string? FirstName,
|
||||
string? LastName,
|
||||
|
||||
@@ -1868,6 +1868,14 @@ body.site-menu-hidden .site-menu-shell {
|
||||
min-height: 3.3rem;
|
||||
}
|
||||
|
||||
.admin-edit-modal-card input[readonly],
|
||||
.admin-readonly-field {
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
background: rgba(255, 255, 255, 0.025);
|
||||
border-color: rgba(255, 255, 255, 0.12);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.admin-edit-modal-card .profile-feedback {
|
||||
margin-bottom: 0.55rem;
|
||||
padding: 0.65rem 0.8rem;
|
||||
|
||||
Reference in New Issue
Block a user