Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding sign-in page.. #21

Open
Prathamesh557 opened this issue Jul 25, 2024 · 6 comments
Open

Regarding sign-in page.. #21

Prathamesh557 opened this issue Jul 25, 2024 · 6 comments

Comments

@Prathamesh557
Copy link

When we enter details on sign-in page , and hit submit , it is not redirecting to dashboard..

I request genuinely Hitesh Sir to please upload the repo of fully working project as this is having alot of issues..

@AbhinavSharma486
Copy link

When we enter details on sign-in page , and hit submit , it is not redirecting to dashboard..

I request genuinely Hitesh Sir to please upload the repo of fully working project as this is having alot of issues..

same issue i also facing

@anshukantjha
Copy link

configure your middleware as per documentation
`import NextAuth from "next-auth"

export const { auth, handlers } = NextAuth({
callbacks: {
authorized: async ({ auth }) => {
// Logged in users are authenticated, otherwise redirect to login page
return !!auth
},
},
})`
Link provided:
https://authjs.dev/getting-started/session-management/protecting#nextjs-middleware
or you can use prop redirectTo there also

@anshukantjha
Copy link

Btw i have issue why result gives redirecturl only it should be a object upon console log
Inside submitHandler as
const submitHandler = async (data: z.infer<typeof signInSchema>) => { try { const result = await postSignIn(data); console.log(result); if (result?.error) { if (result.error === "CredentialsSignin") { toast({

output of result is not expected and that might be also your issue @AbhinavSharma486 @Prathamesh557 cause result object has no url so if (result?.url) { router.replace("/dashboard"); }
these snippet is not excecuted

@Haiderghadi
Copy link

did this issue got solved ?? i am facing the same problem, can anyone help?

@KunalNasa
Copy link

did this issue got solved ?? i am facing the same problem, can anyone help?

I have created a pull request for it. So the problem is that the token is NULL in middleware.ts (You can check by console.log(token)) due to which we are redirecting to sig-in route even when the user is logged in. To resolve this issue you have to provide NEXT_AUTH_TOKEN to your getToken() method.
const token = await getToken({ req: request, secret: process.env.NEXT_AUTH_SECRET });
This will resolve this issue

@Haiderghadi
Copy link

Haiderghadi commented Sep 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants