Replies: 20 comments 13 replies
-
Hi, did u fix this problem? I get same and even worse. After Sign and redirect back, the status is unauthenticated, but the dev env works smooth. |
Beta Was this translation helpful? Give feedback.
-
I'm also having issues with the |
Beta Was this translation helpful? Give feedback.
-
I have the same issue. |
Beta Was this translation helpful? Give feedback.
-
I have the same problem... |
Beta Was this translation helpful? Give feedback.
-
I'm having the same issues. |
Beta Was this translation helpful? Give feedback.
-
I'm having the same issues. Exist a solution? |
Beta Was this translation helpful? Give feedback.
-
Hi,
Did you set up a session callback in your[ …nextauth.js] ?
…On Mon, Jan 16, 2023 at 7:32 PM Eduardo Fortuna ***@***.***> wrote:
I'm having the same issues.
Exist a solution?
—
Reply to this email directly, view it on GitHub
<#5719 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AO4HWVEH4ZDE2EKEEWNHGBTWSXSA7ANCNFSM6AAAAAASYAQSIQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
In my case when I was redirecting in the callback config I was getting this error. I changed my callback config to no longer redirect but instead to return true on successful authentication or return false. callbacks: {
async signIn({ account, profile }) {
const { email_verified } = profile as GoogleProfile;
if (account?.provider === 'google' && email_verified) {
return true;
}
return false;
},
}, On your signIn() click handler you can pass in a callbackUrl to redirect to a different page on your site. signIn('google', { callbackUrl: 'http://localhost:3000/dashboard' }) I would say in OP's issue they would need to use the signIn() method from next-auth and use the callbackUrl. |
Beta Was this translation helpful? Give feedback.
-
In my case it was a problem with the order of components in the entry Before <>
<SessionProvider session={session}>
<OptionalAuth>{children}</OptionalAuth>
</SessionProvider>
</> After <>
<OptionalAuth>
<SessionProvider session={session}>{children}</SessionProvider>
</OptionalAuth>
</> |
Beta Was this translation helpful? Give feedback.
-
Has anyone solved it? I'm having the same issue :( |
Beta Was this translation helpful? Give feedback.
-
same issue :( |
Beta Was this translation helpful? Give feedback.
-
I encountered an issue while attempting to use callbacks for signing in and returning a redirect route. However, I managed to resolve the problem by returning a boolean value. |
Beta Was this translation helpful? Give feedback.
-
I'm also currently experiencing this. Running NextJS in /api/auth/session endpoint returns logged in user. The data in Verbose logging on NextAuth doesn't show anything obvious to look at... |
Beta Was this translation helpful? Give feedback.
-
I fixed it I think. In my |
Beta Was this translation helpful? Give feedback.
-
It seems that after a successful login the /session api is not called. So I did something like the following in my LoginComponent
Edit:
So we use an internal library to execute the signin process on a different backend, I had to do this also on the signIn process, where I give in a callbackUrl and on successful login, I also execute a redirect via window.location.href to the success location and then the session gets correctly loaded. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
same here |
Beta Was this translation helpful? Give feedback.
-
I found a workaround by putting the session logic on SSR with another internal component on the client side containing the rest of the logic: Server: import { auth } from "@/auth";
export default async function Component() {
const session = await auth();
return <ComponentInner session={session} />;
} Client: export default function ComponentInner({ session }: { session: Session | null }) {
console.log(session?.user);
// logic
} |
Beta Was this translation helpful? Give feedback.
-
My workaround involves implementing a session provider that fetches "use client";
import React from "react";
import { Session } from "next-auth";
import { usePathname } from "next/navigation";
type SessionProviderProps = React.PropsWithChildren<{
session?: Session | null;
}>;
const sessionContext = React.createContext<Session | null>(null);
export function SessionProvider({ session: initialSession = null, children }: SessionProviderProps) {
const [session, setSession] = React.useState<Session | null>(initialSession);
const pathname = usePathname();
React.useEffect(() => {
const fetchSession = async () => {
if (!initialSession) {
const fetchedSession = await fetch("/api/auth/session").then((res) => res.json());
setSession(fetchedSession);
}
};
fetchSession();
}, [initialSession, pathname]);
return <sessionContext.Provider value={session}>{children}</sessionContext.Provider>;
}
export function useSession() {
return React.useContext(sessionContext);
} |
Beta Was this translation helpful? Give feedback.
-
Question 💬
Hello i setup next auth with CredentialsProvider
in local work perfectfully but when i deploy it to windows server the issues has found
when i login -> logout -> login the value of status from useSession() is unauthenticated
but the token next-auth.session-token already exists, you can see my image below
this is status from useSession()
this is the cookies
How to reproduce ☕️
This is my [...nextauth].js
and this is my login function
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Beta Was this translation helpful? Give feedback.
All reactions