feat(auth): add Google and GitHub OAuth support

This commit is contained in:
nxtkofi 2026-05-14 23:27:23 +02:00
parent e89537f217
commit 04641f74ff
4 changed files with 51 additions and 0 deletions

View file

@ -51,6 +51,16 @@ export const createAuthOptions = (
}); });
}, },
}, },
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
},
github: {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
},
},
plugins: [convex({ authConfig }), haveIBeenPwned()], plugins: [convex({ authConfig }), haveIBeenPwned()],
}; };
}; };

View file

@ -17,6 +17,9 @@
"ShowPasswordTooltip": "Show password", "ShowPasswordTooltip": "Show password",
"Submit": "Submit", "Submit": "Submit",
"CheckYourEmail": "Check your email to complete the process.", "CheckYourEmail": "Check your email to complete the process.",
"SignInWithGoogle": "Sign in with Google",
"SignInWithGitHub": "Sign in with GitHub",
"OrContinueWith": "or continue with",
"ForgotPasswordLink": "Forgot password?", "ForgotPasswordLink": "Forgot password?",
"ForgotPasswordTitle": "Forgot password", "ForgotPasswordTitle": "Forgot password",
"SendResetLink": "Send reset link", "SendResetLink": "Send reset link",

View file

@ -17,6 +17,9 @@
"ShowPasswordTooltip": "Pokaż hasło", "ShowPasswordTooltip": "Pokaż hasło",
"Submit": "Wyślij", "Submit": "Wyślij",
"CheckYourEmail": "Sprawdź email, aby dokończyć proces.", "CheckYourEmail": "Sprawdź email, aby dokończyć proces.",
"SignInWithGoogle": "Zaloguj się przez Google",
"SignInWithGitHub": "Zaloguj się przez GitHub",
"OrContinueWith": "lub kontynuuj przez",
"ForgotPasswordLink": "Nie pamiętasz hasła?", "ForgotPasswordLink": "Nie pamiętasz hasła?",
"ForgotPasswordTitle": "Nie pamiętasz hasła", "ForgotPasswordTitle": "Nie pamiętasz hasła",
"SendResetLink": "Wyślij link resetujący", "SendResetLink": "Wyślij link resetujący",

View file

@ -38,6 +38,8 @@ import {
TooltipTrigger, TooltipTrigger,
} from '@/components/ui/tooltip'; } from '@/components/ui/tooltip';
import { Separator } from '@/components/ui/separator';
import { Spinner } from '../ui/spinner'; import { Spinner } from '../ui/spinner';
const signInSchema = z.object({ const signInSchema = z.object({
@ -119,6 +121,39 @@ export function AuthForm({ mode, redirectPath = '/dashboard' }: AuthFormProps) {
</CardAction> </CardAction>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="flex flex-col gap-3">
<Button
type="button"
variant="outline"
onClick={() =>
authClient.signIn.social({
provider: 'google',
callbackURL: redirectPath,
})
}
>
{t('SignInWithGoogle')}
</Button>
<Button
type="button"
variant="outline"
onClick={() =>
authClient.signIn.social({
provider: 'github',
callbackURL: redirectPath,
})
}
>
{t('SignInWithGitHub')}
</Button>
</div>
<div className="my-4 flex items-center gap-3">
<Separator className="flex-1" />
<span className="text-muted-foreground text-xs uppercase">
{t('OrContinueWith')}
</span>
<Separator className="flex-1" />
</div>
<form id="form-auth" onSubmit={form.handleSubmit(onSubmit)}> <form id="form-auth" onSubmit={form.handleSubmit(onSubmit)}>
<FieldGroup> <FieldGroup>
{isSignUp && ( {isSignUp && (