forked from baron/baron-sso
fix: verify-only magic link approval flow
This commit is contained in:
@@ -430,11 +430,22 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
debugPrint("[Auth] Starting verification for token: $token");
|
||||
try {
|
||||
// Use Backend to verify the token (Backend-Driven Flow)
|
||||
final res = await AuthProxyService.verifyMagicLink(token);
|
||||
final res = await AuthProxyService.verifyMagicLink(
|
||||
token,
|
||||
verifyOnly: _verificationOnly,
|
||||
);
|
||||
debugPrint("[Auth] Verification successful for token: $token");
|
||||
final jwt = res['token'] ?? res['sessionJwt'];
|
||||
final status = res['status']?.toString();
|
||||
final hasLocalSession = await _hasValidLocalSession();
|
||||
|
||||
if (status == 'approved' || (jwt == null && _verificationOnly)) {
|
||||
if (mounted) {
|
||||
_markVerificationApproved("승인되었습니다. 로그인은 요청하신 창에서 완료됩니다.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (jwt is String && jwt.isNotEmpty) {
|
||||
if (hasLocalSession) {
|
||||
_markVerificationApproved(
|
||||
@@ -442,14 +453,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
);
|
||||
return;
|
||||
}
|
||||
_markVerificationApproved(
|
||||
"링크로 로그인 되었습니다. 잠시 후 로그인 화면으로 이동합니다.",
|
||||
title: '링크 로그인 완료',
|
||||
pageTitle: '링크 로그인',
|
||||
actionLabel: '로그인 화면으로 이동',
|
||||
actionPath: '/signin',
|
||||
autoRedirect: true,
|
||||
);
|
||||
_markVerificationApproved("승인되었습니다. 로그인은 요청하신 창에서 완료됩니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -492,8 +496,11 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
);
|
||||
return;
|
||||
}
|
||||
_markVerificationApproved(
|
||||
"링크로 로그인 되었습니다. 잠시 후 로그인 화면으로 이동합니다.",
|
||||
if (_verificationOnly) {
|
||||
_markVerificationApproved("승인되었습니다. 로그인은 요청하신 창에서 완료됩니다.");
|
||||
return;
|
||||
}
|
||||
_markVerificationApproved("링크로 로그인 되었습니다. 잠시 후 로그인 화면으로 이동합니다.",
|
||||
title: '링크 로그인 완료',
|
||||
pageTitle: '링크 로그인',
|
||||
actionLabel: '로그인 화면으로 이동',
|
||||
@@ -539,6 +546,10 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (_verificationOnly) {
|
||||
_markVerificationApproved("승인되었습니다. 로그인은 요청하신 창에서 완료됩니다.");
|
||||
return;
|
||||
}
|
||||
_completeLoginFromToken(jwt, provider: res['provider'] as String?);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user