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;
|
guestId?: string;
|
||||||
}): Promise<Result<LoginResponse>> {
|
}): Promise<Result<LoginResponse>> {
|
||||||
return Result.wrap(async () => {
|
return Result.wrap(async () => {
|
||||||
|
const email = input.email?.trim() ?? "";
|
||||||
const response = await this.api.emailLogin(
|
const response = await this.api.emailLogin(
|
||||||
LoginRequest.from(
|
LoginRequest.from(
|
||||||
withTestAccountFlag({
|
withTestAccountFlag({
|
||||||
email: input.email ?? "",
|
email,
|
||||||
username: input.username ?? "",
|
username: resolveLoginUsername(input.username, email),
|
||||||
password: input.password,
|
password: input.password,
|
||||||
platform: getAuthPlatform(),
|
platform: getAuthPlatform(),
|
||||||
guestId: input.guestId ?? "",
|
guestId: input.guestId ?? "",
|
||||||
@@ -332,3 +333,11 @@ function withTestAccountFlag<T extends Record<string, unknown>>(
|
|||||||
function getAuthPlatform(): string {
|
function getAuthPlatform(): string {
|
||||||
return PlatformDetector.getPlatform();
|
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