feat(oauth): Refactor platform parameter handling and improve logout redirection logic

This commit is contained in:
web@ppanel 2025-01-21 22:39:23 +07:00
parent aa6dda894b
commit 8346c85109
3 changed files with 22 additions and 12 deletions

View File

@ -29,6 +29,7 @@ export default function Certification({ platform, children }: CertificationProps
case 'google': case 'google':
return googleLoginCallback(body); return googleLoginCallback(body);
case 'telegram': case 'telegram':
// 回调参数是 # 开头的,需要去掉
return telegramLoginCallback(body); return telegramLoginCallback(body);
default: default:
break; break;

View File

@ -5,25 +5,33 @@ import { getTranslations } from 'next-intl/server';
import Certification from './certification'; import Certification from './certification';
export async function generateStaticParams() { export async function generateStaticParams() {
return { return [
paths: [ {
{ params: { platform: 'telegram' } }, platform: 'telegram',
{ params: { platform: 'apple' } }, },
{ params: { platform: 'facebook' } }, {
{ params: { platform: 'google' } }, platform: 'apple',
{ params: { platform: 'github' } }, },
], {
fallback: false, platform: 'facebook',
}; },
{
platform: 'google',
},
{
platform: 'github',
},
];
} }
export default async function Page({ export default async function Page({
params: { platform }, params,
}: { }: {
params: { params: {
platform: string; platform: string;
}; };
}) { }) {
const { platform } = await params;
const t = await getTranslations('auth'); const t = await getTranslations('auth');
return ( return (
<Certification platform={platform}> <Certification platform={platform}>

View File

@ -45,7 +45,8 @@ export function Logout() {
if (!isBrowser()) return; if (!isBrowser()) return;
cookies.remove('Authorization'); cookies.remove('Authorization');
const pathname = location.pathname; const pathname = location.pathname;
if (!['', '/', '/auth', '/tos', '/oauth'].includes(pathname)) { console.log(pathname);
if (!['', '/', '/auth', '/tos'].includes(pathname) || !pathname.includes('/oauth/')) {
setRedirectUrl(location.pathname); setRedirectUrl(location.pathname);
location.href = `/auth`; location.href = `/auth`;
} }