chore: fix opt login

This commit is contained in:
nathan
2025-10-01 11:40:51 +08:00
parent 79543bcb19
commit 43018befdb

View File

@@ -5,6 +5,7 @@ import { afterAuth } from '@/application/session/sign_in';
import { getTokenParsed, refreshToken as refreshSessionToken } from '@/application/session/token';
import { parseGoTrueError } from './gotrue-error';
import { verifyToken } from './http_api';
export * from './gotrue-error';
@@ -186,11 +187,18 @@ export async function signInOTP({
if (data) {
if (!data.code) {
refreshSessionToken(JSON.stringify(data));
if (type === 'magiclink') {
emit(EventType.SESSION_VALID);
}
try {
await verifyToken(data.access_token);
refreshSessionToken(JSON.stringify(data));
} catch (error) {
console.error('Failed to verify token with AppFlowy Cloud:', error);
emit(EventType.SESSION_INVALID, { error });
}
afterAuth();
} else {
emit(EventType.SESSION_INVALID);