recommended way to force a user signIn from server side?
Unanswered
American black bear posted this in #help-forum
Original message was deleted.
10 Replies
Original message was deleted
middleware
@@ts-ignore middleware
American black bear
what do you mean? a client component that uses signIn instead?
@American black bear what do you mean? a client component that uses signIn instead?
check the user in middleware and redirect accordingly or https://next-auth.js.org/getting-started/client#require-session
@@ts-ignore check the user in middleware and redirect accordingly or https://next-auth.js.org/getting-started/client#require-session
American black bear
thats my question, redirecting like this
redirect('/api/auth/signin'); brings up a login page that the user has to click a button to sign in, i was asking if there is a way to have the same functionality as signIn("dscord") without having to have a client component.American black bear
thank you i shall give that a try soon 🙂
American black bear
@@ts-ignore Hi, thanks for the response. I tried what you suggested but unfortunately this results in an error:
In the allowed auth types it says signin is allowed though, so im unsure why this is happening
UnknownAction: Unsupported action. Read more at https://errors.authjs.dev#unknownactionIn the allowed auth types it says signin is allowed though, so im unsure why this is happening
Burmese
If you're asking for signin functionality but not from a client component (ie by clicking sign in), you're going to find that to be challenging.
What is wrong with redirecting the user to the login page or to a login button to log in again?
@Burmese What is wrong with redirecting the user to the login page or to a login button to log in again?
American black bear
friction, want it to be as simple as possible. I think what I'll do is just redirect them page that uses a client component so i can use signIn there.
Thank you for the responses 🙂
Thank you for the responses 🙂