summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/auth/components/LoginDesktop.jsx10
-rw-r--r--src/pages/api/auth/[...nextauth].js40
2 files changed, 32 insertions, 18 deletions
diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx
index 74d259a8..f5aa0018 100644
--- a/src/lib/auth/components/LoginDesktop.jsx
+++ b/src/lib/auth/components/LoginDesktop.jsx
@@ -9,8 +9,8 @@ const LoginDesktop = () => {
const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } =
useLogin()
- const {data : session } = useSession
- console.log('ini google', session)
+ const { data } = useSession()
+ console.log('ini google', data)
return (
<DesktopView>
@@ -66,10 +66,10 @@ const LoginDesktop = () => {
</form>
<button
type='submit'
- className='btn-red w-full mt-2'
- onClick={() => signIn()}
+ className='border border-gray-500 p-3 rounded-md hover:bg-gray-100 w-full mt-2'
+ onClick={() => signIn('google')}
>
- Masuk dengan google
+ Masuk dengan Google
</button>
<div className='text-gray_r-11 mt-10'>
diff --git a/src/pages/api/auth/[...nextauth].js b/src/pages/api/auth/[...nextauth].js
index f1d6a31f..6cc8a101 100644
--- a/src/pages/api/auth/[...nextauth].js
+++ b/src/pages/api/auth/[...nextauth].js
@@ -1,15 +1,29 @@
-import NextAuth from "next-auth/next";
-import GoogleProvider from "next-auth/providers/google"
+import NextAuth from 'next-auth/next'
+import GoogleProvider from 'next-auth/providers/google'
export default NextAuth({
- providers:[
- GoogleProvider({
- clientId: process.env.GOOGLE_CLIENT_ID,
- clientSecret: process.env.GOOGLE_CLIENT_SECRET,
- }),
- ],
- secret:process.env.JWT_SECRET
- // pages:{
- // signIn: '/login',
- // }
-}) \ No newline at end of file
+ providers: [
+ GoogleProvider({
+ clientId: process.env.GOOGLE_CLIENT_ID,
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET
+ })
+ ],
+ callbacks: {
+ async jwt({ token, account }) {
+ // Persist the OAuth access_token to the token right after signin
+ if (account) {
+ token.accessToken = account.access_token
+ }
+ return token
+ },
+ async session({ session, token, user }) {
+ // Send properties to the client, like an access_token from a provider.
+ session.accessToken = token.accessToken
+ return session
+ }
+ },
+ secret:process.env.JWT_SECRET
+ // pages:{
+ // signIn: '/login',
+ // }
+})