@@ -20,7 +20,7 @@ import { InputOTP, InputOTPGroup, InputOTPSlot } from "~/components/primitives/I
2020import { Paragraph } from "~/components/primitives/Paragraph" ;
2121import { Spinner } from "~/components/primitives/Spinner" ;
2222import { authenticator } from "~/services/auth.server" ;
23- import { commitSession , getUserSession , sessionStorage } from "~/services/sessionStorage.server" ;
23+ import { commitSession , getUserSession } from "~/services/sessionStorage.server" ;
2424import { getSession as getMessageSession } from "~/models/message.server" ;
2525import { MultiFactorAuthenticationService } from "~/services/mfa/multiFactorAuthentication.server" ;
2626import { redirectWithErrorMessage , redirectBackWithErrorMessage } from "~/models/message.server" ;
@@ -152,17 +152,16 @@ export async function action({ request }: ActionFunctionArgs) {
152152}
153153
154154async function completeLogin ( request : Request , session : Session , userId : string ) {
155- // Create a new authenticated session
156- const authSession = await sessionStorage . getSession ( request . headers . get ( "Cookie" ) ) ;
157- authSession . set ( authenticator . sessionKey , { userId } ) ;
155+ // Set the auth key on the same session object to avoid conflicting Set-Cookie headers
156+ // (both authSession and session share the same __session cookie name)
157+ session . set ( authenticator . sessionKey , { userId } ) ;
158158
159159 // Get the redirect URL and clean up pending MFA data
160160 const redirectTo = session . get ( "pending-mfa-redirect-to" ) ?? "/" ;
161161 session . unset ( "pending-mfa-user-id" ) ;
162162 session . unset ( "pending-mfa-redirect-to" ) ;
163163
164164 const headers = new Headers ( ) ;
165- headers . append ( "Set-Cookie" , await sessionStorage . commitSession ( authSession ) ) ;
166165 headers . append ( "Set-Cookie" , await commitSession ( session ) ) ;
167166
168167 await trackAndClearReferralSource ( request , userId , headers ) ;
0 commit comments