feat(frontend): add username editing
This commit is contained in:
parent
5a8b7aae80
commit
2a66e3e25e
10 changed files with 164 additions and 23 deletions
|
@ -22,19 +22,27 @@ public class MetaController : ApiControllerBase
|
|||
),
|
||||
new Limits(
|
||||
MemberCount: MembersController.MaxMemberCount,
|
||||
BioLength: ValidationUtils.MaxBioLength))
|
||||
BioLength: ValidationUtils.MaxBioLength,
|
||||
CustomPreferences: UsersController.MaxCustomPreferences))
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("/api/v2/coffee")]
|
||||
public IActionResult BrewCoffee() => Problem("Sorry, I'm a teapot!", statusCode: StatusCodes.Status418ImATeapot);
|
||||
|
||||
private record MetaResponse(string Repository, string Version, string Hash, int Members, UserInfo Users, Limits Limits);
|
||||
private record MetaResponse(
|
||||
string Repository,
|
||||
string Version,
|
||||
string Hash,
|
||||
int Members,
|
||||
UserInfo Users,
|
||||
Limits Limits);
|
||||
|
||||
private record UserInfo(int Total, int ActiveMonth, int ActiveWeek, int ActiveDay);
|
||||
|
||||
// All limits that the frontend should know about (for UI purposes)
|
||||
private record Limits(
|
||||
int MemberCount,
|
||||
int BioLength);
|
||||
int BioLength,
|
||||
int CustomPreferences);
|
||||
}
|
|
@ -177,14 +177,16 @@ public class UsersController(
|
|||
public bool Favourite { get; set; }
|
||||
}
|
||||
|
||||
public const int MaxCustomPreferences = 25;
|
||||
|
||||
private static List<(string, ValidationError?)> ValidateCustomPreferences(
|
||||
List<CustomPreferencesUpdateRequest> preferences)
|
||||
{
|
||||
var errors = new List<(string, ValidationError?)>();
|
||||
|
||||
if (preferences.Count > 25)
|
||||
if (preferences.Count > MaxCustomPreferences)
|
||||
errors.Add(("custom_preferences",
|
||||
ValidationError.LengthError("Too many custom preferences", 0, 25, preferences.Count)));
|
||||
ValidationError.LengthError("Too many custom preferences", 0, MaxCustomPreferences, preferences.Count)));
|
||||
if (preferences.Count > 50) return errors;
|
||||
|
||||
// TODO: validate individual preferences
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue