René's URL Explorer Experiment


Title: fix(webapp): let an admin switch impersonation target without stopping first by isshaddad · Pull Request #4576 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: fix(webapp): let an admin switch impersonation target without stopping first by isshaddad · Pull Request #4576 · triggerdotdev/trigger.dev

X Title: fix(webapp): let an admin switch impersonation target without stopping first by isshaddad · Pull Request #4576 · triggerdotdev/trigger.dev

Description: getUserId resolves to the impersonated user id while impersonating — by design, so requireUser answers "who is this request acting as". Every impersonation entry point gated on it, so while impersonating one user, user.admin was that user's flag and starting on a second target silently redirected to /. You had to stop impersonating first, then start again. Changes getRealUser resolves the authenticated user, ignoring the impersonation cookie. It applies the same session controls getUserId applies to the real user — SSO revalidation and the auto-logout deadline — so it can't become a way around them. redirectWithImpersonation gates on it rather than taking a user from the caller, and attributes the audit row to the real admin. Previously that row would have named the impersonated user as the actor. The route moved to admin_.impersonate.tsx, opting out of the admin.tsx layout, whose requireSuper gate resolves the same impersonated identity. Nesting left the fix depending on the router preferring the deepest redirect. It now checks canSuper() against the real admin directly — the raw User.admin column only equals canSuper() in the OSS fallback, and a plugin is free to be stricter. Unauthenticated requests redirect to login carrying the original URL, so the impersonation link survives the round trip. The one-time token is validated after the gate, so it's still unconsumed. The view-as-user flag is cleared when the target changes. It's scoped to a single impersonation session, which is why stopping impersonation already dropped it. Switching straight between targets never passes through clearImpersonation, so a STOP for the previous target is written alongside the new START. Both go in one transaction with explicit timestamps: Postgres now() is the transaction timestamp, so the default would stamp both rows identically and an audit view ordered by that column couldn't tell which came first. Testing No automated coverage — the behaviour needs a real session plus an impersonation cookie, and the integration test that covered it isn't included here. It was verified locally against a real Postgres container, including reproducing the original bug by making the gate resolve the impersonation target and confirming it fails. Worth a manual pass before merge: Impersonate one user, then start on a second without stopping — you should land on the second directly. ImpersonationAuditLog shows STOP then START, both with the admin's id as adminId. The view-as-user toggle doesn't follow you across the switch. Clicking the impersonate link while signed out returns you to it after login. Split out of #4571, which bundled this with an unrelated customer-card fix.

Open Graph Description: getUserId resolves to the impersonated user id while impersonating — by design, so requireUser answers "who is this request acting as". Every impersonation entry point gated on it, so whi...

X Description: getUserId resolves to the impersonated user id while impersonating — by design, so requireUser answers "who is this request acting as". Every impersonation entry point gated on it...

Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/4576

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:75d5f75d-dec2-a2b2-0347-e5e97bab8717
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id83BA:3776CB:34DE9BE:48403AD:6AFAF5CE
html-safe-nonce5dcfef52520bf389e64dbaa90456c353bd77f08b544e5236a509f02adde3c823
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0JBOjM3NzZDQjozNERFOUJFOjQ4NDAzQUQ6NkFGQUY1Q0UiLCJ2aXNpdG9yX2lkIjoiODI1MzE0MTAzNTMxMjE0OTk2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8a9d8a683a4ef3f7b63030bf70c79f985b036e7019bea104101c4112cb89a4ae
hovercard-subject-tagpull_request:4257371769
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/4576/files
twitter:imagehttps://avatars.githubusercontent.com/u/74388823?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/74388823?s=400&v=4
og:image:altgetUserId resolves to the impersonated user id while impersonating — by design, so requireUser answers "who is this request acting as". Every impersonation entry point gated on it, so whi...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0178036d8230524a18422872393ab7e708443ae4c2047f758560a2db870c1913
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git
octolytics-dimension-user_id95297378
octolytics-dimension-user_logintriggerdotdev
octolytics-dimension-repository_id572570113
octolytics-dimension-repository_nwotriggerdotdev/trigger.dev
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id572570113
octolytics-dimension-repository_network_root_nwotriggerdotdev/trigger.dev
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea85e96a83bed7871993e6b1ffda24105928eee17
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/pull/4576/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4576%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4576%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
triggerdotdevhttps://github.com/triggerdotdev
trigger.devhttps://github.com/triggerdotdev/trigger.dev
Codehttps://github.com/triggerdotdev/trigger.dev
Issues203 (203)https://github.com/triggerdotdev/trigger.dev/issues
Pull requests67 (67)https://github.com/triggerdotdev/trigger.dev/pulls
Discussionshttps://github.com/triggerdotdev/trigger.dev/discussions
Actionshttps://github.com/triggerdotdev/trigger.dev/actions
Projectshttps://github.com/triggerdotdev/trigger.dev/projects
Security and quality39 (39)https://github.com/triggerdotdev/trigger.dev/security
Insightshttps://github.com/triggerdotdev/trigger.dev/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
isshaddadhttps://github.com/isshaddad
mainhttps://github.com/triggerdotdev/trigger.dev/tree/main
fix/impersonation-switch-targethttps://github.com/triggerdotdev/trigger.dev/tree/fix/impersonation-switch-target
Conversation 11 https://github.com/triggerdotdev/trigger.dev/pull/4576
Commits 1 https://github.com/triggerdotdev/trigger.dev/pull/4576/commits
Checks 38 https://github.com/triggerdotdev/trigger.dev/pull/4576/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/4576/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
fix(webapp): let an admin switch impersonation target without stopping first https://github.com/triggerdotdev/trigger.dev/pull/4576/files#top
Show all changes 1 commit https://github.com/triggerdotdev/trigger.dev/pull/4576/files
539e792 fix(webapp): let an admin switch impersonation target without stoppin… isshaddad Aug 11, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4576/commits/539e792b04a8548e6dc6f2893097976efe128cc0
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/4576/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
admin.server.ts https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-8d2b2e02299782414c09715c09e8f6d8b735138e699e5b05d574bde159e6c420
_app.@.orgs.$organizationSlug.$.tsx https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-a35fa02418311030f2c2d2cc5b33b7bd4661110924f122f236538b3747645295
admin.impersonate.tsx https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-4044ef607a1260f8d0d089b964f9627772e6894a57e2b14a1c676cb5ac757bf1
admin_.impersonate.tsx https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-0831fd50d8eb06cf4e58e534a919dc6d8b1f5c32d122274804bfe247bdbcc3e2
impersonation.server.ts https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-bbb056cb93bc10685a2100d2258a5bfad7cfce2b78acdd597e9013140be84912
session.server.ts https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-29ba17ba87f7943e0d20fa2c2a3daa2cfd697e8daba40e37d99d76903afd5b8e
apps/webapp/app/models/admin.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-8d2b2e02299782414c09715c09e8f6d8b735138e699e5b05d574bde159e6c420
View file https://github.com/triggerdotdev/trigger.dev/blob/539e792b04a8548e6dc6f2893097976efe128cc0/apps/webapp/app/models/admin.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4576/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-8d2b2e02299782414c09715c09e8f6d8b735138e699e5b05d574bde159e6c420
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-8d2b2e02299782414c09715c09e8f6d8b735138e699e5b05d574bde159e6c420
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-8d2b2e02299782414c09715c09e8f6d8b735138e699e5b05d574bde159e6c420
coderabbitaihttps://github.com/apps/coderabbitai
Aug 11, 2026https://github.com/triggerdotdev/trigger.dev/pull/4576/files#r3762135518
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
coderabbitaihttps://github.com/apps/coderabbitai
Aug 11, 2026https://github.com/triggerdotdev/trigger.dev/pull/4576/files#r3762135532
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
devin-ai-integrationhttps://github.com/apps/devin-ai-integration
Aug 11, 2026https://github.com/triggerdotdev/trigger.dev/pull/4576/files#r3762135159
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/4576
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-8d2b2e02299782414c09715c09e8f6d8b735138e699e5b05d574bde159e6c420
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-8d2b2e02299782414c09715c09e8f6d8b735138e699e5b05d574bde159e6c420
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-8d2b2e02299782414c09715c09e8f6d8b735138e699e5b05d574bde159e6c420
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-8d2b2e02299782414c09715c09e8f6d8b735138e699e5b05d574bde159e6c420
apps/webapp/app/routes/_app.@.orgs.$organizationSlug.$.tsxhttps://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-a35fa02418311030f2c2d2cc5b33b7bd4661110924f122f236538b3747645295
View file https://github.com/triggerdotdev/trigger.dev/blob/539e792b04a8548e6dc6f2893097976efe128cc0/apps/webapp/app/routes/_app.%40.orgs.%24organizationSlug.%24.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4576/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-a35fa02418311030f2c2d2cc5b33b7bd4661110924f122f236538b3747645295
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-a35fa02418311030f2c2d2cc5b33b7bd4661110924f122f236538b3747645295
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-a35fa02418311030f2c2d2cc5b33b7bd4661110924f122f236538b3747645295
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-a35fa02418311030f2c2d2cc5b33b7bd4661110924f122f236538b3747645295
apps/webapp/app/routes/admin.impersonate.tsxhttps://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-4044ef607a1260f8d0d089b964f9627772e6894a57e2b14a1c676cb5ac757bf1
View file https://github.com/triggerdotdev/trigger.dev/blob/45696579233527dade718676f6d9622d69409f9b/apps/webapp/app/routes/admin.impersonate.tsx
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
apps/webapp/app/routes/admin_.impersonate.tsxhttps://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-0831fd50d8eb06cf4e58e534a919dc6d8b1f5c32d122274804bfe247bdbcc3e2
View file https://github.com/triggerdotdev/trigger.dev/blob/539e792b04a8548e6dc6f2893097976efe128cc0/apps/webapp/app/routes/admin_.impersonate.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4576/{{ revealButtonHref }}
devin-ai-integrationhttps://github.com/apps/devin-ai-integration
Aug 11, 2026https://github.com/triggerdotdev/trigger.dev/pull/4576/files#r3762135004
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/4576
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
coderabbitaihttps://github.com/apps/coderabbitai
Aug 11, 2026https://github.com/triggerdotdev/trigger.dev/pull/4576/files#r3762135539
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
coderabbitaihttps://github.com/apps/coderabbitai
Aug 11, 2026https://github.com/triggerdotdev/trigger.dev/pull/4576/files#r3762135551
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
apps/webapp/app/services/impersonation.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-bbb056cb93bc10685a2100d2258a5bfad7cfce2b78acdd597e9013140be84912
View file https://github.com/triggerdotdev/trigger.dev/blob/539e792b04a8548e6dc6f2893097976efe128cc0/apps/webapp/app/services/impersonation.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4576/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-bbb056cb93bc10685a2100d2258a5bfad7cfce2b78acdd597e9013140be84912
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-bbb056cb93bc10685a2100d2258a5bfad7cfce2b78acdd597e9013140be84912
apps/webapp/app/services/session.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-29ba17ba87f7943e0d20fa2c2a3daa2cfd697e8daba40e37d99d76903afd5b8e
View file https://github.com/triggerdotdev/trigger.dev/blob/539e792b04a8548e6dc6f2893097976efe128cc0/apps/webapp/app/services/session.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4576/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-29ba17ba87f7943e0d20fa2c2a3daa2cfd697e8daba40e37d99d76903afd5b8e
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-29ba17ba87f7943e0d20fa2c2a3daa2cfd697e8daba40e37d99d76903afd5b8e
https://github.com/triggerdotdev/trigger.dev/pull/4576/files#diff-29ba17ba87f7943e0d20fa2c2a3daa2cfd697e8daba40e37d99d76903afd5b8e
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4576/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.