Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions 9 apps/webapp/app/routes/login.mfa/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { InputOTP, InputOTPGroup, InputOTPSlot } from "~/components/primitives/I
import { Paragraph } from "~/components/primitives/Paragraph";
import { Spinner } from "~/components/primitives/Spinner";
import { authenticator } from "~/services/auth.server";
import { commitSession, getUserSession, sessionStorage } from "~/services/sessionStorage.server";
import { commitSession, getUserSession } from "~/services/sessionStorage.server";
import { getSession as getMessageSession } from "~/models/message.server";
import { MultiFactorAuthenticationService } from "~/services/mfa/multiFactorAuthentication.server";
import { redirectWithErrorMessage, redirectBackWithErrorMessage } from "~/models/message.server";
Expand Down Expand Up @@ -152,17 +152,16 @@ export async function action({ request }: ActionFunctionArgs) {
}

async function completeLogin(request: Request, session: Session, userId: string) {
// Create a new authenticated session
const authSession = await sessionStorage.getSession(request.headers.get("Cookie"));
authSession.set(authenticator.sessionKey, { userId });
// Set the auth key on the same session object to avoid conflicting Set-Cookie headers
// (both authSession and session share the same __session cookie name)
session.set(authenticator.sessionKey, { userId });

// Get the redirect URL and clean up pending MFA data
const redirectTo = session.get("pending-mfa-redirect-to") ?? "/";
session.unset("pending-mfa-user-id");
session.unset("pending-mfa-redirect-to");

const headers = new Headers();
headers.append("Set-Cookie", await sessionStorage.commitSession(authSession));
headers.append("Set-Cookie", await commitSession(session));

await trackAndClearReferralSource(request, userId, headers);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.