fix(auth): trim email and username in emailLogin method

This commit is contained in:
2026-06-30 15:15:35 +08:00
parent 2c96d5144c
commit 61504050e5
+11 -2
View File
@@ -70,11 +70,12 @@ export class AuthRepository implements IAuthRepository {
guestId?: string;
}): Promise<Result<LoginResponse>> {
return Result.wrap(async () => {
const email = input.email?.trim() ?? "";
const response = await this.api.emailLogin(
LoginRequest.from(
withTestAccountFlag({
email: input.email ?? "",
username: input.username ?? "",
email,
username: resolveLoginUsername(input.username, email),
password: input.password,
platform: getAuthPlatform(),
guestId: input.guestId ?? "",
@@ -332,3 +333,11 @@ function withTestAccountFlag<T extends Record<string, unknown>>(
function getAuthPlatform(): string {
return PlatformDetector.getPlatform();
}
function resolveLoginUsername(
username: string | undefined,
email: string,
): string {
const trimmedUsername = username?.trim() ?? "";
return trimmedUsername.length > 0 ? trimmedUsername : email;
}