fiex(Login): redirect

feature/artists
mackt 7 months ago
parent b0d8c342ac
commit 445c27c69e

@ -68,7 +68,7 @@ export default function LoginForm({ className }: { className?: string }) {
if (result.code === 200) { if (result.code === 200) {
setShowLogin(false); setShowLogin(false);
await getUserInfo(); await getUserInfo();
router.replace(redirect); if (redirect) router.replace(redirect);
} else { } else {
setErrorText(result.message); setErrorText(result.message);
setBtnLoading(false); setBtnLoading(false);

@ -1,8 +1,8 @@
import { useSearchParams } from 'next/navigation'; import { useSearchParams } from 'next/navigation';
export const useLoginRedirect = () => { export const useLoginRedirect: () => string | null = () => {
const searchParams = useSearchParams(); const searchParams = useSearchParams();
const redirect = searchParams.get('redirect'); const redirect = searchParams.get('redirect');
if (!redirect) return '/'; if (!redirect) return null;
return redirect; return redirect;
}; };

Loading…
Cancel
Save