#Bug, session not refreshing on log out

4 messages · Page 1 of 1 (latest)

rotund marten
#

I have github provider configured, log in is smooth, but when I click log out, nothing is changed until I either reload or simply alt tab to another window or even if i go to another tab and back then the changes are reflected

coarse harnessBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

rotund marten
#

anyone please??

#

import { PrismaAdapter } from "@auth/prisma-adapter";
import NextAuth from "next-auth";
import GitHub from "next-auth/providers/github";
import { getSession } from "next-auth/react";
import { prisma } from "./lib/prisma";
import { authConfig } from "./auth.config";

export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [
GitHub({
authorization: {
params: {
scope: "read:user user:email repo read:org", // Request read access to user info and repositories
},
},
}),
],

callbacks: {
...authConfig.callbacks,
// Store the GitHub access token in the token object
async jwt({ token, account }) {
if (account) {
token.accessToken = account.access_token; // Store access token
}
return token;
},
// Add access token to the session object
async session({ session, token }) {
session.accessToken = token.accessToken; // Add access token to session
if (session.accessToken) {
const res = await fetch("https://api.github.com/user", {
headers: {
Authorization: token ${session.accessToken},
Accept: "application/vnd.github.v3+json",
"Cache-Control": "no-cache",
},
});

    if (res.ok) {
      const userData = await res.json();
      session.user.github = userData;
    }
  }

  return session;
},

},
// adapter: PrismaAdapter(prisma),
});