From f01f28a7eac76c6da5bf857bfc80fd347586ce7f Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Wed, 16 Aug 2023 09:39:47 +0700
Subject: register google

---
 src/lib/auth/components/LoginDesktop.jsx | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

(limited to 'src/lib/auth/components/LoginDesktop.jsx')

diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx
index 06c90d45..3a7477b9 100644
--- a/src/lib/auth/components/LoginDesktop.jsx
+++ b/src/lib/auth/components/LoginDesktop.jsx
@@ -7,9 +7,8 @@ import { useSession, signIn, SignOut } from 'next-auth/react'
 import Image from 'next/image'
 import { useRouter } from 'next/router'
 import { useContext, useEffect, useState } from 'react'
-import Spinner from '@/core/components/elements/Spinner/Spinner'
-import { AuthContext } from '@/pages/_app'
 import { getAuth, setAuth } from '@/core/utils/auth'
+import { setCookie } from 'cookies-next'
 
 const LoginDesktop = () => {
   const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } =
@@ -19,7 +18,6 @@ const LoginDesktop = () => {
   const [query, setQuery] = useState(router?.query?.next || '/')
   const { data: session } = useSession()
   const auth = getAuth()
-  const { setAuthenticated } = useContext(AuthContext)
 
   const handleGoogle = async () => {
     const url = query != '/' ? '/login?next=' + query : '/login'
@@ -27,10 +25,11 @@ const LoginDesktop = () => {
   }
 
   useEffect(() => {
-    if (session || auth) {
-      setAuthenticated(session ? session.odooUser : auth)
+    if(session){
+      setCookie('auth', JSON.stringify(session?.odooUser))
+      router.push(query)
     }
-  }, [session])
+  },[session])
 
   return (
     <DesktopView>
-- 
cgit v1.2.3

