Fixed error with update of password in database
This commit is contained in:
@@ -28,6 +28,7 @@ public class PatchUserPasswordEndpoint(UsersRepository usersRepository, UserServ
|
||||
}
|
||||
|
||||
string salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next();
|
||||
user.Salt = salt;
|
||||
user.Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt);
|
||||
|
||||
await usersRepository.SaveChangesAsync(ct);
|
||||
|
||||
@@ -39,5 +39,6 @@ public class UpdateUserEndpoint(UsersRepository usersRepository, UserService use
|
||||
|
||||
await usersRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
await Send.OkAsync(await usersRepository.ProjectToSingleAsync<GetUserDetailsDto>(new GetUserByIdSpec(userId), ct), ct);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public class PatchUserPasswordDtoValidator : Validator<PatchUserPasswordDto>
|
||||
.NotEmpty()
|
||||
.WithMessage("Password is required")
|
||||
.MinimumLength(12)
|
||||
.WithMessage("Password must exceed 12 characters");
|
||||
.WithMessage("Password must exceed 12 characters")
|
||||
.Matches(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*?[#?_!@$%^&*-])");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user