-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(webapp): app auto session logout #3473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
samejr
wants to merge
19
commits into
main
Choose a base branch
from
feat(webapp)-auto-app-logout
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6813adf
Implements new session logout
samejr 2bc0b77
Submit the form without a save button
samejr 83e779d
Better settings layout
samejr 434ca8f
Show friendly labels for capped duration values
samejr a3d7239
Bug fix: When getting logged out, logging back in redirected you to /…
samejr a719118
Fixes bug where session logout returned error.
samejr fb57aa6
Remove login page toast message logic
samejr 4804b00
Cloudwatch picks up session logout events
samejr 5a8b888
small classname tweak
samejr 96730fa
Aggregate the session length values
samejr 36ef44f
Merge the 2 db migrations
samejr 287f566
userId param is no longer used
samejr 8062e16
Fix for ensuring a DB change updates the availble duration options
samejr 2726647
Code review fixes and improvements
samejr de992dd
Code review improvements
samejr c22cbf2
Merge branch 'main' into feat(webapp)-auto-app-logout
samejr 9faf77f
Code review fix
samejr b768149
code comment update
samejr ba141be
Merge branch 'main' into feat(webapp)-auto-app-logout
samejr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
apps/webapp/app/routes/admin.api.v1.orgs.$organizationId.session-duration.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { type ActionFunctionArgs, json } from "@remix-run/server-runtime"; | ||
| import { z } from "zod"; | ||
| import { prisma } from "~/db.server"; | ||
| import { requireAdminApiRequest } from "~/services/personalAccessToken.server"; | ||
| import { | ||
| ALLOWED_SESSION_DURATION_VALUES, | ||
| isAllowedSessionDuration, | ||
| } from "~/services/sessionDuration.server"; | ||
|
|
||
| const ParamsSchema = z.object({ | ||
| organizationId: z.string(), | ||
| }); | ||
|
|
||
| const RequestBodySchema = z.object({ | ||
| /** | ||
| * Maximum session lifetime (seconds) for members of this organization, or | ||
| * null to remove the cap. When set, this caps each member's | ||
| * `User.sessionDuration` and is enforced on the user's next request. | ||
| * | ||
| * Must be one of the values in `SESSION_DURATION_OPTIONS` so the cap always | ||
| * maps to a labeled dropdown option for users — otherwise users see fallback | ||
| * labels like "7200 seconds" in the UI. To allow a new value, add it to | ||
| * `SESSION_DURATION_OPTIONS`. | ||
| */ | ||
| maxSessionDuration: z | ||
| .number() | ||
| .int() | ||
| .positive() | ||
| .nullable() | ||
| .refine((v) => v === null || isAllowedSessionDuration(v), { | ||
| message: `maxSessionDuration must be one of: ${[...ALLOWED_SESSION_DURATION_VALUES] | ||
| .sort((a, b) => a - b) | ||
| .join(", ")}`, | ||
| }), | ||
| }); | ||
|
|
||
| export async function action({ request, params }: ActionFunctionArgs) { | ||
| await requireAdminApiRequest(request); | ||
|
|
||
| const { organizationId } = ParamsSchema.parse(params); | ||
| const parseResult = RequestBodySchema.safeParse(await request.json()); | ||
| if (!parseResult.success) { | ||
| return json({ success: false, errors: parseResult.error.flatten() }, { status: 400 }); | ||
| } | ||
| const body = parseResult.data; | ||
|
|
||
| const organization = await prisma.organization.update({ | ||
| where: { id: organizationId }, | ||
| data: { maxSessionDuration: body.maxSessionDuration }, | ||
| select: { id: true, slug: true, maxSessionDuration: true }, | ||
| }); | ||
|
samejr marked this conversation as resolved.
|
||
|
|
||
| return json({ success: true, organization }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.