fix(auth): revoke JWT on logout and harden Google sign-in
Some checks failed
CI / Lint, Test & Build (push) Failing after 7m49s
CI / Deploy production (on server) (push) Has been cancelled

Logout now increments sessionVersion so existing JWTs are rejected
server-side, deletes orphaned DB sessions, and uses redirectTo for signOut.
Google OAuth requests account selection each time; optional AUTH_GOOGLE_PROMPT=login
forces Google re-authentication on shared devices.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Antigravity
2026-05-17 17:29:51 +00:00
parent 5b794d6449
commit db175ebff6
15 changed files with 89 additions and 16 deletions

View File

@@ -2,14 +2,20 @@ import { LoginForm } from '@/components/login-form';
import { getSystemConfig } from '@/lib/config';
import { isGoogleAuthEnabled } from '@/lib/auth-providers';
export default async function LoginPage() {
export default async function LoginPage({
searchParams,
}: {
searchParams: Promise<{ error?: string }>;
}) {
const config = await getSystemConfig();
const allowRegister = config.ALLOW_REGISTRATION !== 'false' && process.env.ALLOW_REGISTRATION !== 'false';
const { error: authError } = await searchParams;
return (
<LoginForm
allowRegister={allowRegister}
googleAuthEnabled={isGoogleAuthEnabled()}
authError={authError}
/>
);
}

View File

@@ -4,7 +4,7 @@ import { useState } from 'react'
import { Input } from '@/components/ui/input'
import { updateProfile, changePassword } from '@/app/actions/profile'
import { updateUserSettings } from '@/app/actions/user-settings'
import { signOut } from 'next-auth/react'
import { performSignOut } from '@/lib/auth-client'
import { toast } from 'sonner'
import { useLanguage } from '@/lib/i18n'
import { User, Mail, Shield, LogOut, Camera, Bell } from 'lucide-react'
@@ -143,7 +143,7 @@ export function ProfileForm({ user }: { user: { name: string | null; email: stri
{/* Logout */}
<div className="pt-8 border-t border-border/40">
<button
onClick={() => signOut({ callbackUrl: '/login' })}
onClick={() => performSignOut('/login')}
className="flex items-center gap-3 px-6 py-3 bg-rose-50 dark:bg-rose-500/10 text-rose-600 rounded-xl font-bold uppercase tracking-widest text-[10px] hover:bg-rose-100 transition-colors"
>
<LogOut size={16} />