From fce459679c3d7794342c5f9f553a04fec8bea46e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= Date: Mon, 6 Jan 2025 16:51:30 +0100 Subject: [PATCH] feat: update session handling by changing import source and enhancing token scope --- src/app/layout.tsx | 2 +- src/authOptions.ts | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 72bd773..282f20a 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,4 +1,4 @@ -import { getSession } from "@/authOptions"; +import { getSession } from "next-auth/react"; import AppWrapper from "./components/AppWrapper"; import "./globals.css"; diff --git a/src/authOptions.ts b/src/authOptions.ts index 356aa6e..46ebe52 100644 --- a/src/authOptions.ts +++ b/src/authOptions.ts @@ -1,10 +1,9 @@ import axios from "axios"; import moment from "moment"; -import { AuthOptions, getServerSession, Session } from "next-auth"; +import { AuthOptions, Session } from "next-auth"; import { JWT } from "next-auth/jwt"; import jsonwebtoken from "jsonwebtoken"; import { JWTDecoded } from "./app/types/next-auth"; -import { cache } from "react"; moment.locale("fr"); @@ -19,7 +18,7 @@ export const authOptions: AuthOptions = { authorization: { url: process.env.OAUTH_AUTHORIZATION_URL, params: { - scope: "openid email profile", + scope: "openid email profile offline_access", response_type: "code", }, }, @@ -139,5 +138,3 @@ const refreshAccessToken = async (token: JWT): Promise => { return refreshPromise; }; - -export const getSession = cache(() => getServerSession());