Trigger signIn('okta') programmatically (Next 14 & Next-auth 5 beta.13 )
Unanswered
Capelin posted this in #help-forum
CapelinOP
Hello, in middleware.ts, I redirect calls if the user is not logged in to a page called login. On the login page, I have this simple signIn code. Clicking on the button takes users to the Okta login page, which is expected. Now I am wondering how I can skip this button click and directly take users to the provider's login page.
I appreciate your help and suggestions.
import { signIn } from '@/auth';
const SignIn = () => {
return (
<form
action={async () => {
'use server';
await signIn('okta' );
}}
>
<button type='submit'>Sign in with Okta</button>
</form>
)
}
export default SignIn;
I appreciate your help and suggestions.
import { signIn } from '@/auth';
const SignIn = () => {
return (
<form
action={async () => {
'use server';
await signIn('okta' );
}}
>
<button type='submit'>Sign in with Okta</button>
</form>
)
}
export default SignIn;
1 Reply
@Capelin Hello, in middleware.ts, I redirect calls if the user is not logged in to a page called login. On the login page, I have this simple signIn code. Clicking on the button takes users to the Okta login page, which is expected. Now I am wondering how I can skip this button click and directly take users to the provider's login page.
I appreciate your help and suggestions.
import { signIn } from '@/auth';
const SignIn = () => {
return (
<form
action={async () => {
'use server';
await signIn('okta' );
}}
>
<button type='submit'>Sign in with Okta</button>
</form>
)
}
export default SignIn;
Yellowstripe scad
if thats your only provider I would just make the signin button on the navbar do the signIn action onclick and not have a login page