mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
fix: add validation for display name length in user creation and update requests
This commit is contained in:
@@ -32,6 +32,8 @@ namespace SharpbinV3.Server.Controllers
|
||||
}
|
||||
if (!IsValidPassword(request.Password))
|
||||
return BadRequest(new { message = "Password should have at least 8 characters, including uppercase, lowercase, and digits." });
|
||||
if (!string.IsNullOrEmpty(request.DisplayName) && request.DisplayName.Length > 26)
|
||||
return BadRequest(new { message = "Display name should not exceed 26 characters." });
|
||||
|
||||
var user = await _authService.CreateUser(request.Username, request.Password, request.Email, request.DisplayName);
|
||||
return Ok(new
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace SharpbinV3.Server.DTOs
|
||||
if (DisplayName != null) {
|
||||
if (DisplayName.Length < 3 || DisplayName.Length > 26)
|
||||
{
|
||||
results.Add(new ValidationResult("DisplayName must be between 3 and 50 characters.", [nameof(DisplayName)]));
|
||||
results.Add(new ValidationResult("DisplayName must be between 3 and 26 characters.", [nameof(DisplayName)]));
|
||||
}
|
||||
}
|
||||
if (Email != null)
|
||||
|
||||
Reference in New Issue
Block a user