mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
fix!: normalize and make usernames unique
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user