feat(auth): replace TOTP with phone-first login

This commit is contained in:
2026-07-28 17:39:29 +08:00
parent e7d350ec3d
commit c7f9a4e3c9
43 changed files with 18386 additions and 882 deletions

View File

@@ -0,0 +1,24 @@
using Microsoft.AspNetCore.Identity;
namespace Tiku.Infrastructure.Auth;
public sealed class LetterAndDigitPasswordValidator<TUser> : IPasswordValidator<TUser>
where TUser : class
{
public Task<IdentityResult> ValidateAsync(
UserManager<TUser> manager,
TUser user,
string? password)
{
var valid = password is { Length: >= 8 } &&
password.Any(char.IsLetter) &&
password.Any(char.IsDigit);
return Task.FromResult(valid
? IdentityResult.Success
: IdentityResult.Failed(new IdentityError
{
Code = "PasswordRequiresLetterAndDigit",
Description = "Password must be at least 8 characters and contain both letters and digits."
}));
}
}