Skip to content

Commit e69909a

Browse files
committed
Fix: clear impersonation when already impersonating
Fix for when switching impersonating
1 parent 4ede32c commit e69909a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apps/webapp/app/routes/_app.@.orgs.$organizationSlug.$.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import { requireUser } from "~/services/session.server";
77

88
export async function loader({ request, params }: LoaderFunctionArgs) {
99
const user = await requireUser(request);
10+
11+
// If already impersonating, we need to clear the impersonation
12+
if (user.isImpersonating) {
13+
const url = new URL(request.url);
14+
return clearImpersonation(request, url.pathname);
15+
}
16+
17+
// Only admins can impersonate
1018
if (!user.admin) {
1119
return redirect("/");
1220
}

0 commit comments

Comments
 (0)