Fix Impersonation Refresh Bug (#5679)

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
pull/5675/head^2
sean-brydon 2022-11-25 12:36:33 +00:00 committed by GitHub
parent 2a6dc340df
commit 93a14b190e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 21 deletions

View File

@ -16,9 +16,7 @@ function AdminView() {
onSubmit={(e) => {
e.preventDefault();
const enteredUsername = usernameRef.current?.value.toLowerCase();
signIn("impersonation-auth", { username: enteredUsername }).then((res) => {
console.log(res);
});
signIn("impersonation-auth", { username: enteredUsername });
}}>
<div className="flex items-center space-x-2">
<TextField

View File

@ -1,8 +1,7 @@
import { useSession } from "next-auth/react";
import { Trans } from "next-i18next";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Alert } from "@calcom/ui";
import { TopBanner } from "@calcom/ui";
function ImpersonatingBanner() {
const { t } = useLocale();
@ -11,21 +10,17 @@ function ImpersonatingBanner() {
if (!data?.user.impersonatedByUID) return null;
return (
<Alert
severity="warning"
title={
<>
{t("impersonating_user_warning", { user: data.user.username })}{" "}
<Trans i18nKey="impersonating_stop_instructions">
<a href="/auth/logout" className="underline">
Click Here To stop
</a>
.
</Trans>
</>
}
className="mx-4 mb-2 sm:mx-6 md:mx-8"
/>
<>
<TopBanner
text={t("impersonating_user_warning", { user: data.user.username })}
variant="warning"
actions={
<a className="border-b border-b-black" href="/auth/logout">
Click Here To stop
</a>
}
/>
</>
);
}

View File

@ -17,7 +17,7 @@ export default function AdminLayout({
// Force redirect on component level
useEffect(() => {
if (session.data && session.data.user.role !== UserPermissionRole.ADMIN) {
router.replace("/settings");
router.replace("/settings/my-account/profile");
}
}, [session, router]);