Replies: 2 comments
-
I am facing the same problem |
Beta Was this translation helpful? Give feedback.
0 replies
-
Me too. Has this problem been solved? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello fellow programmers! This is not an issue, is more of a ask for help situation since i am a new dev.
I am trying to implement next auth v5 in my app, using next 14.
I have a route which is /new-product, and i when i visit this route i check if the user is logged in, and if it is not, it will return to the login page:
--//--
auth.config.ts
import type { NextAuthConfig } from 'next-auth';
import { auth } from './auth';
export const authConfig = {
pages: {
signIn: '/login',
},
callbacks: {
authorized({ auth, request: { nextUrl } }) {
const isLoggedIn = auth?.user;
const isOnNewProduct = nextUrl.pathname.startsWith('/new-product');
//console.log(isOnNewProduct);
console.log("Is Logged in: " + isLoggedIn);
console.log("Is on New Product: " + isOnNewProduct);
},
providers: [], // Add providers with an empty array for now
} satisfies NextAuthConfig;
--//--
In the login page i have a form with user and password, and i check after login my user session:
--//--
import LoginForm from "../components/login-form";
import { auth } from "../../auth";
export default async function Login (){
}
--//--
In the auth.config.ts file my auth?.user is allways null, even ater i log in, and in my login page, after i login my session object contains the user and when session expires...
I do not understant why auth.user is allways null. Can someone help me please?
If there is a need for better clarification please let me know
Regards
Beta Was this translation helpful? Give feedback.
All reactions