fix(auth): trim email and username in emailLogin method
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user