Skip to content

Commit fb57aa6

Browse files
committed
Remove login page toast message logic
1 parent a719118 commit fb57aa6

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

apps/webapp/app/services/session.server.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { redirect } from "@remix-run/node";
2-
import { redirectWithErrorMessage } from "~/models/message.server";
32
import { getUserById } from "~/models/user.server";
43
import { sanitizeRedirectPath } from "~/utils";
54
import { authenticator } from "./auth.server";
@@ -32,12 +31,7 @@ export async function getUserId(request: Request): Promise<string | undefined> {
3231
const session = await getUserSession(request);
3332
const { durationSeconds } = await getEffectiveSessionDuration(authUser.userId);
3433
if (isSessionExpired(session, durationSeconds)) {
35-
throw await redirectWithErrorMessage(
36-
"/logout",
37-
request,
38-
"You were signed out due to inactivity.",
39-
{ ephemeral: false }
40-
);
34+
throw redirect("/logout");
4135
}
4236

4337
return authUser.userId;

apps/webapp/app/services/sessionDuration.server.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,32 +156,38 @@ export function ensureSessionIssuedAt(session: Session, now: number = Date.now()
156156
}
157157

158158
/**
159-
* Commits the session for an authenticated user, setting `issuedAt = now` and
160-
* the cookie's `Max-Age` to the effective session duration. Use this at every
161-
* login/MFA-completion point so the session window starts fresh.
159+
* The auth cookie's `Max-Age` is intentionally long (1 year) so the cookie
160+
* always reaches the server. Actual session expiry is enforced server-side
161+
* via `sessionIssuedAt` against the user's effective duration. If we let the
162+
* cookie expire client-side, the user is silently logged out without the
163+
* "signed out due to inactivity" toast.
164+
*/
165+
const AUTH_COOKIE_MAX_AGE_SECONDS = DEFAULT_SESSION_DURATION_SECONDS;
166+
167+
/**
168+
* Commits the session for an authenticated user, setting `issuedAt = now`.
169+
* Use this at every login/MFA-completion point so the session window starts
170+
* fresh. Cookie `Max-Age` is fixed; expiry is enforced server-side.
162171
*/
163172
export async function commitAuthenticatedSession(
164173
session: Session,
165-
userId: string,
174+
_userId: string,
166175
now: number = Date.now()
167176
): Promise<string> {
168-
const { durationSeconds } = await getEffectiveSessionDuration(userId);
169177
setSessionIssuedAt(session, now);
170-
return commitSession(session, { maxAge: durationSeconds });
178+
return commitSession(session, { maxAge: AUTH_COOKIE_MAX_AGE_SECONDS });
171179
}
172180

173181
/**
174182
* Commits the session for an authenticated user, lazily backfilling
175183
* `issuedAt` if missing. Use on every authenticated response that already
176-
* commits the cookie (e.g. root.tsx) so legacy cookies migrate forward and
177-
* the browser's stored Max-Age tracks the latest effective duration.
184+
* commits the cookie (e.g. root.tsx).
178185
*/
179186
export async function commitAuthenticatedSessionLazy(
180187
session: Session,
181-
userId: string,
188+
_userId: string,
182189
now: number = Date.now()
183190
): Promise<string> {
184-
const { durationSeconds } = await getEffectiveSessionDuration(userId);
185191
ensureSessionIssuedAt(session, now);
186-
return commitSession(session, { maxAge: durationSeconds });
192+
return commitSession(session, { maxAge: AUTH_COOKIE_MAX_AGE_SECONDS });
187193
}

0 commit comments

Comments
 (0)