feat(auth): restore Google sign-in and AI admin test routes
Google OAuth was implemented locally but never deployed; the login button only renders when AUTH_GOOGLE_ID and AUTH_GOOGLE_SECRET are set. Also restores /api/ai/test-* endpoints removed by mistake and wires Google credentials into deploy workflows. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
21
memento-note/components/google-sign-in-button.tsx
Normal file
21
memento-note/components/google-sign-in-button.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
'use client';
|
||||
|
||||
import { signIn } from 'next-auth/react';
|
||||
|
||||
export function GoogleSignInButton({ label }: { label: string }) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => signIn('google', { callbackUrl: '/home' })}
|
||||
className="w-full flex items-center justify-center gap-3 py-4 rounded-2xl border border-[var(--border)] bg-white dark:bg-white/5 text-sm font-medium hover:bg-slate-50 dark:hover:bg-white/10 transition-all"
|
||||
>
|
||||
<svg width="18" height="18" viewBox="0 0 48 48" aria-hidden>
|
||||
<path fill="#FFC107" d="M43.611 20.083H42V20H24v8h11.303C33.654 32.657 29.203 36 24 36c-6.627 0-12-5.373-12-12s5.373-12 12-12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C33.64 6.053 28.991 4 24 4 12.955 4 4 12.955 4 24s8.955 20 20 20 20-8.955 20-20c0-1.341-.138-2.65-.389-3.917z" />
|
||||
<path fill="#FF3D00" d="m6.306 14.691 6.571 4.819C14.655 15.108 18.961 12 24 12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C33.64 6.053 28.991 4 24 4 16.318 4 9.656 8.337 6.306 14.691z" />
|
||||
<path fill="#4CAF50" d="M24 44c5.166 0 9.86-1.977 13.409-5.192l-6.19-5.238C29.211 35.091 26.715 36 24 36c-5.202 0-9.619-3.317-11.283-7.946l-6.522 5.025C9.505 39.556 16.227 44 24 44z" />
|
||||
<path fill="#1976D2" d="M43.611 20.083H42V20H24v8h11.303a12.04 12.04 0 0 1-4.087 5.571l.003-.002 6.19 5.238C36.971 39.205 44 34 44 24c0-1.341-.138-2.65-.389-3.917z" />
|
||||
</svg>
|
||||
{label}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,19 @@ import { authenticate } from '@/app/actions/auth';
|
||||
import Link from 'next/link';
|
||||
import { Mail, Lock, ArrowRight, Sparkles } from 'lucide-react';
|
||||
import { useLanguage } from '@/lib/i18n';
|
||||
import { GoogleSignInButton } from '@/components/google-sign-in-button';
|
||||
|
||||
function AuthDivider({ label }: { label: string }) {
|
||||
return (
|
||||
<div className="relative flex items-center py-2">
|
||||
<div className="flex-grow border-t border-[var(--border)]" />
|
||||
<span className="mx-4 text-[10px] uppercase tracking-widest text-[var(--muted-foreground)] font-bold">
|
||||
{label}
|
||||
</span>
|
||||
<div className="flex-grow border-t border-[var(--border)]" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LoginButton() {
|
||||
const { pending } = useFormStatus();
|
||||
@@ -28,7 +41,13 @@ function LoginButton() {
|
||||
);
|
||||
}
|
||||
|
||||
export function LoginForm({ allowRegister = true }: { allowRegister?: boolean }) {
|
||||
export function LoginForm({
|
||||
allowRegister = true,
|
||||
googleAuthEnabled = false,
|
||||
}: {
|
||||
allowRegister?: boolean;
|
||||
googleAuthEnabled?: boolean;
|
||||
}) {
|
||||
const [errorMessage, dispatch] = useActionState(authenticate, undefined);
|
||||
const { t } = useLanguage();
|
||||
|
||||
@@ -44,6 +63,13 @@ export function LoginForm({ allowRegister = true }: { allowRegister?: boolean })
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{googleAuthEnabled && (
|
||||
<>
|
||||
<GoogleSignInButton label={t('auth.continueWithGoogle')} />
|
||||
<AuthDivider label={t('auth.orContinueWith')} />
|
||||
</>
|
||||
)}
|
||||
|
||||
<form action={dispatch} className="space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-[10px] uppercase tracking-widest font-bold text-[var(--muted-foreground)] px-4">
|
||||
|
||||
@@ -6,6 +6,7 @@ import { register } from '@/app/actions/register';
|
||||
import Link from 'next/link';
|
||||
import { Mail, Lock, User, ArrowRight, Sparkles } from 'lucide-react';
|
||||
import { useLanguage } from '@/lib/i18n';
|
||||
import { GoogleSignInButton } from '@/components/google-sign-in-button';
|
||||
|
||||
function RegisterButton() {
|
||||
const { pending } = useFormStatus();
|
||||
@@ -28,7 +29,19 @@ function RegisterButton() {
|
||||
);
|
||||
}
|
||||
|
||||
export function RegisterForm() {
|
||||
function AuthDivider({ label }: { label: string }) {
|
||||
return (
|
||||
<div className="relative flex items-center py-2">
|
||||
<div className="flex-grow border-t border-[var(--border)]" />
|
||||
<span className="mx-4 text-[10px] uppercase tracking-widest text-[var(--muted-foreground)] font-bold">
|
||||
{label}
|
||||
</span>
|
||||
<div className="flex-grow border-t border-[var(--border)]" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function RegisterForm({ googleAuthEnabled = false }: { googleAuthEnabled?: boolean }) {
|
||||
const [errorMessage, dispatch] = useActionState(register, undefined);
|
||||
const { t } = useLanguage();
|
||||
|
||||
@@ -44,6 +57,13 @@ export function RegisterForm() {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{googleAuthEnabled && (
|
||||
<>
|
||||
<GoogleSignInButton label={t('auth.continueWithGoogle')} />
|
||||
<AuthDivider label={t('auth.orContinueWith')} />
|
||||
</>
|
||||
)}
|
||||
|
||||
<form action={dispatch} className="space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-[10px] uppercase tracking-widest font-bold text-[var(--muted-foreground)] px-4">
|
||||
|
||||
Reference in New Issue
Block a user