-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
I can't find a way to implement Magic Email Auth in my Remix App using WorkOS Authkit for Authentication. I tried the following code, it adds the cookie, but it's not signing me in. Please help!!!
const { code } = await workos.userManagement.getMagicAuth(id)
if (code !== otp) {
return Response.json(
{ errors: { otp: 'Invalid OTP' } },
{ status: 400 },
)
}
// Authenticate with WorkOS
const session = await workos.userManagement.authenticateWithMagicAuth({
clientId: process.env.WORKOS_CLIENT_ID as string,
code: otp,
email,
})
// Get the AuthKit session storage
const sessionStorage = await getSessionStorage()
// Create the session using the proper WorkOS method
const authkitSession = await sessionStorage.getSession()
// Store the entire session object correctly
authkitSession.set('user', session.user)
authkitSession.set('accessToken', session.accessToken)
authkitSession.set('refreshToken', session.refreshToken)
// Redirect with the session cookie properly set
return redirect('/', {
headers: {
'Set-Cookie': await sessionStorage.commitSession(authkitSession),
},
})
Metadata
Metadata
Assignees
Labels
No labels