mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: admins can change user's roles
refactor: banned role has priority over all other roles when displaying chore: npm run format
This commit is contained in:
@@ -8,6 +8,7 @@ namespace SharpbinV3.Server.DTOs
|
||||
public string? DisplayName { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public int? Visibility { get; set; } = 0;
|
||||
public int[]? Roles { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate()
|
||||
{
|
||||
@@ -30,6 +31,18 @@ namespace SharpbinV3.Server.DTOs
|
||||
if (Visibility < 0 || Visibility > 2)
|
||||
results.Add(new ValidationResult("Visibility must be between 0 and 2.", [nameof(Visibility)]));
|
||||
}
|
||||
if (Roles != null)
|
||||
{
|
||||
if (Roles.Length == 0)
|
||||
results.Add(new ValidationResult("Roles cannot be an empty array.", [nameof(Roles)]));
|
||||
int[] validRoles = [0, 1, 255, 403];
|
||||
foreach (var role in Roles)
|
||||
{
|
||||
if (!validRoles.Contains(role))
|
||||
results.Add(new ValidationResult($"Invalid role: {role}.", [nameof(Roles)]));
|
||||
}
|
||||
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user