@@ -332,8 +332,9 @@ async function tryConsumeOAuthCallback() {
332332 const q = route .query ;
333333 const oauthError = q .oauth_error as string | undefined ;
334334 const access = q .access_token as string | undefined ;
335+ const oauthSession = q .oauth === " 1" ;
335336
336- if (! oauthError && ! access ) return ;
337+ if (! oauthError && ! access && ! oauthSession ) return ;
337338
338339 // OAuth 弹窗:跨域授权后 opener 可能被 COOP 断开,用同源 localStorage 事件回传。
339340 if (window .name === " fastapiadmin-oauth" || q .oauth_popup === " 1" ) {
@@ -355,6 +356,7 @@ async function tryConsumeOAuthCallback() {
355356 delete rest .access_token ;
356357 delete rest .refresh_token ;
357358 delete rest .token_type ;
359+ delete rest .oauth ;
358360 delete rest .oauth_popup ;
359361
360362 if (oauthError ) {
@@ -363,6 +365,29 @@ async function tryConsumeOAuthCallback() {
363365 return ;
364366 }
365367
368+ if (oauthSession ) {
369+ try {
370+ await userStore .refreshTokenFn ();
371+ await userStore .getUserInfo ();
372+ await configStore .getConfig (true );
373+ userStore .setLoginStatus (true );
374+ ElNotification ({
375+ title: t (" login.oauthNoticeTitle" ),
376+ message: t (" login.oauthLoginSuccess" ),
377+ type: " success" ,
378+ });
379+ await router .replace (oauthRedirectTarget (rest as Record <string , unknown >));
380+ if (settingStore .showGuide ) {
381+ appStore .showGuide (true );
382+ }
383+ } catch (error ) {
384+ console .error (" [Login] OAuth session:" , error );
385+ ElMessage .error (t (" login.oauthLoginFailed" ));
386+ await router .replace ({ path: route .path , query: rest as LocationQuery });
387+ }
388+ return ;
389+ }
390+
366391 if (access ) {
367392 try {
368393 // refresh token 由后端写入 HttpOnly Cookie,URL 不再携带
0 commit comments