fix!: normalize and make usernames unique

This commit is contained in:
2026-06-13 20:10:01 -04:00
parent a2a030936c
commit 18c20cdf64
6 changed files with 667 additions and 3 deletions
+2 -2
View File
@@ -45,7 +45,7 @@ namespace SharpbinV3.Server.Services
{
var user = new User
{
Username = username,
Username = UserService.NormalizeUsername(username),
PasswordHash = Bcrypt.HashPassword(password),
Email = email,
DisplayName = displayName,
@@ -181,7 +181,7 @@ namespace SharpbinV3.Server.Services
public async Task<User> UpdateUser(User user)
{
var existingUser = await _db.Users.FirstOrDefaultAsync(u => u.UUID == user.UUID) ?? throw new Exception("User not found");
existingUser.Username = user.Username;
existingUser.Username = UserService.NormalizeUsername(user.Username);
existingUser.Email = user.Email;
existingUser.DisplayName = user.DisplayName;
existingUser.Roles = user.Roles;