add google provider

上级 a76df723
...@@ -32,6 +32,8 @@ POSTGRES_DATABASE="" ...@@ -32,6 +32,8 @@ POSTGRES_DATABASE=""
# Providers # Providers
GITHUB_ID="" GITHUB_ID=""
GITHUB_SECRET="" GITHUB_SECRET=""
GOOGLE_ID=""
GOOGLE_SECRET=""
# Auth config # Auth config
NEXTAUTH_SECRET="" NEXTAUTH_SECRET=""
......
import Signin from '@/components/layout/Signin'; import Signin from '@/components/Signin';
export const metadata = { export const metadata = {
title: 'Tabler Sign in', title: 'Tabler Sign in',
......
import Signup from '@/components/layout/Signup'; import Signup from '@/components/Signup';
export const metadata = { export const metadata = {
title: 'Tabler Sign up', title: 'Tabler Sign up',
......
...@@ -8,7 +8,7 @@ import { signIn } from 'next-auth/react'; ...@@ -8,7 +8,7 @@ import { signIn } from 'next-auth/react';
export default function Signin() { export default function Signin() {
const router = useRouter();'/'; const router = useRouter();'/';
const handleLogin = async (provider: 'github'): Promise<void> => { const handleLogin = async (provider: 'github' | 'google'): Promise<void> => {
await signIn(provider, {callbackUrl: '/'}); await signIn(provider, {callbackUrl: '/'});
}; };
...@@ -47,6 +47,12 @@ export default function Signin() { ...@@ -47,6 +47,12 @@ export default function Signin() {
Login with Github Login with Github
</a> </a>
</div> </div>
<div className="col">
<a onClick={() => handleLogin('google')} className="btn w-100">
{/* <Icon name="brand-google"/> */}
Login with Google
</a>
</div>
</div> </div>
</div> </div>
</div> </div>
......
import prisma from '@/lib/prisma';
import { PrismaAdapter } from '@next-auth/prisma-adapter'; import { PrismaAdapter } from '@next-auth/prisma-adapter';
import GitHubProvider from 'next-auth/providers/github'; import GitHubProvider from 'next-auth/providers/github';
import prisma from '@/lib/prisma'; import GoogleProvider from 'next-auth/providers/google';
export const authConfig = { export const authConfig = {
providers: [ providers: [
...@@ -8,6 +9,10 @@ export const authConfig = { ...@@ -8,6 +9,10 @@ export const authConfig = {
clientId: process.env.GITHUB_ID as string, clientId: process.env.GITHUB_ID as string,
clientSecret: process.env.GITHUB_SECRET as string, clientSecret: process.env.GITHUB_SECRET as string,
}), }),
GoogleProvider({
clientId: process.env.GOOGLE_ID as string,
clientSecret: process.env.GOOGLE_SECRET as string,
}),
], ],
pages: { pages: {
signIn: '/signin', signIn: '/signin',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册