Multiple SignIn pages #7819
Replies: 7 comments 3 replies
-
Any plans? |
Beta Was this translation helpful? Give feedback.
-
same issue |
Beta Was this translation helpful? Give feedback.
-
This person also have the same problem: I'm also having this problem, my app needs 2 roles of user: admin and user Userawait signIn<"credentials">("credentials", {
username: data.get("username")!.toString(),
password: data.get("password")!.toString(),
redirect: false,
role: "user",
callbackUrl: "/",
}); Adminawait signIn<"credentials">("credentials", {
username: data.get("username")!.toString(),
password: data.get("password")!.toString(),
redirect: false,
role: "admin",
callbackUrl: "/admin/dashboard",
}); In if (credentials.role == "admin") {
const res = await api.POST("/api/v1/auth/admin/login", {
body: credentials,
headers: { "Content-Type": "application/json" },
});
} else if (credentials.role == "user") {
const res = await api.POST("/api/v1/auth/user/login", {
body: credentials,
headers: { "Content-Type": "application/json" },
});
} BUT, the problem, nextauth only support ONE session only.
|
Beta Was this translation helpful? Give feedback.
-
Just ran into this, seems like no obvious solution right now |
Beta Was this translation helpful? Give feedback.
-
same issue, any plans? |
Beta Was this translation helpful? Give feedback.
-
Hi, anyone has update on this, I am trying to implement the same. Thank you in advance |
Beta Was this translation helpful? Give feedback.
-
Facing the same issue, couldn't find any straightforward way to do this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
My app has 2 way for a user to login (Using credentials, we don't use 3rd party OAuth)
I have 2 separate api endpoints
The requirement is as follows
/admin/login
/login
In NextAuth, we can specify only one custom signIn page url as
OR
If i use either of the two values in
pages.signIn
, and callsignIn()
function from another page, then next-auth will redirect me to the mentioned signIn pageHow can i make it such that next-auth accepts both
/admin/login
and/login
as acceptable routes to render login page and when i callsignIn()
from either page, then it sends it as a POST request instead of GETMind you that I cannot add a selector while logging in that chooses between superadmin and user as the as the requirement is strictly as mentioned above.
Thank you.
How to reproduce ☕️
File: app/api/auth/[...nextauth]/route.ts
File: /app/admin/login/page.tsx
SuperAdminLoginTemplate Component:
What do I do in UserLoginTemplateComponent?
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Beta Was this translation helpful? Give feedback.
All reactions