diff --git a/src/data/repositories/auth_repository.ts b/src/data/repositories/auth_repository.ts index 171976ce..e33dfc6e 100644 --- a/src/data/repositories/auth_repository.ts +++ b/src/data/repositories/auth_repository.ts @@ -70,11 +70,12 @@ export class AuthRepository implements IAuthRepository { guestId?: string; }): Promise> { 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>( function getAuthPlatform(): string { return PlatformDetector.getPlatform(); } + +function resolveLoginUsername( + username: string | undefined, + email: string, +): string { + const trimmedUsername = username?.trim() ?? ""; + return trimmedUsername.length > 0 ? trimmedUsername : email; +}