diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-08-14 15:04:45 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-08-14 15:04:45 +0700 |
| commit | 01e86fb4a54b801a9b8124455611c312e5de4af0 (patch) | |
| tree | 09733a6f9fff4c8624bd4a2f2c514d8b16cc684b /src/pages/api/auth | |
| parent | 4cfe9157d64a76bf9913fe599d908497a18f5316 (diff) | |
google sign in
Diffstat (limited to 'src/pages/api/auth')
| -rw-r--r-- | src/pages/api/auth/[...nextauth].js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/pages/api/auth/[...nextauth].js b/src/pages/api/auth/[...nextauth].js index 6cc8a101..b11ed097 100644 --- a/src/pages/api/auth/[...nextauth].js +++ b/src/pages/api/auth/[...nextauth].js @@ -1,3 +1,4 @@ +import odooApi from '@/core/api/odooApi' import NextAuth from 'next-auth/next' import GoogleProvider from 'next-auth/providers/google' @@ -10,20 +11,20 @@ export default NextAuth({ ], 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 + const params = { + access_token: session.accessToken + } + const data = await odooApi('POST', '/api/v1/user/validate-sso', params) + session.odooUser = data.user return session } }, - secret:process.env.JWT_SECRET - // pages:{ - // signIn: '/login', - // } + secret: process.env.JWT_SECRET }) |
