11import { type MetaFunction } from "@remix-run/react" ;
2- import { LoaderFunctionArgs } from "@remix-run/server-runtime" ;
2+ import type { LoaderFunctionArgs } from "@remix-run/server-runtime" ;
33import { typedjson , useTypedLoaderData } from "remix-typedjson" ;
44import {
55 MainHorizontallyCenteredContainer ,
@@ -8,12 +8,10 @@ import {
88} from "~/components/layout/AppLayout" ;
99import { Header2 } from "~/components/primitives/Headers" ;
1010import { NavBar , PageTitle } from "~/components/primitives/PageHeader" ;
11- import { prisma } from "~/db.server" ;
1211import { requireUser } from "~/services/session.server" ;
1312import {
14- DEFAULT_SESSION_DURATION_SECONDS ,
1513 getAllowedSessionOptions ,
16- getOrganizationSessionCap ,
14+ getEffectiveSessionDuration ,
1715} from "~/services/sessionDuration.server" ;
1816import { MfaSetup } from "../resources.account.mfa.setup/route" ;
1917import { SessionDurationSetting } from "../resources.account.session-duration/SessionDurationSetting" ;
@@ -29,20 +27,12 @@ export const meta: MetaFunction = () => {
2927export async function loader ( { request } : LoaderFunctionArgs ) {
3028 const user = await requireUser ( request ) ;
3129
32- const [ userRecord , orgCapSeconds ] = await Promise . all ( [
33- prisma . user . findUnique ( {
34- where : { id : user . id } ,
35- select : { sessionDuration : true } ,
36- } ) ,
37- getOrganizationSessionCap ( user . id ) ,
38- ] ) ;
39-
40- const sessionDuration = userRecord ?. sessionDuration ?? DEFAULT_SESSION_DURATION_SECONDS ;
41- const sessionDurationOptions = getAllowedSessionOptions ( orgCapSeconds , sessionDuration ) ;
30+ const { durationSeconds, orgCapSeconds } = await getEffectiveSessionDuration ( user . id ) ;
31+ const sessionDurationOptions = getAllowedSessionOptions ( orgCapSeconds , durationSeconds ) ;
4232
4333 return typedjson ( {
4434 user,
45- sessionDuration,
35+ sessionDuration : durationSeconds ,
4636 sessionDurationOptions,
4737 orgCapSeconds,
4838 } ) ;
0 commit comments