* fix: rename checkPermission to be more fitting * feat:return to user * nits: cleanup plus comments * cleanup * test: Add e2e * fix: fix fixtures * nit: cleanup logs * chore: move to impersonatedBy in session * fix: can return to self * Update apps/web/playwright/impersonation.e2e.ts * fix: typecheck --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { signIn } from "next-auth/react";
|
|
import { useRef } from "react";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { Button, Meta, TextField } from "@calcom/ui";
|
|
|
|
import PageWrapper from "@components/PageWrapper";
|
|
import { getLayout } from "@components/auth/layouts/AdminLayout";
|
|
|
|
function AdminView() {
|
|
const { t } = useLocale();
|
|
const usernameRef = useRef<HTMLInputElement>(null);
|
|
|
|
return (
|
|
<>
|
|
<Meta title={t("admin")} description={t("impersonation")} />
|
|
<form
|
|
className="mb-6 w-full sm:w-1/2"
|
|
onSubmit={(e) => {
|
|
e.preventDefault();
|
|
const enteredUsername = usernameRef.current?.value.toLowerCase();
|
|
signIn("impersonation-auth", { username: enteredUsername });
|
|
}}>
|
|
<div className="flex items-center space-x-2 rtl:space-x-reverse">
|
|
<TextField
|
|
containerClassName="w-full"
|
|
name={t("user_impersonation_heading")}
|
|
addOnLeading={<>{process.env.NEXT_PUBLIC_WEBSITE_URL}/</>}
|
|
ref={usernameRef}
|
|
hint={t("impersonate_user_tip")}
|
|
defaultValue={undefined}
|
|
data-testid="admin-impersonation-input"
|
|
/>
|
|
<Button type="submit" data-testid="impersonation-submit">
|
|
{t("impersonate")}
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
</>
|
|
);
|
|
}
|
|
|
|
AdminView.getLayout = getLayout;
|
|
AdminView.PageWrapper = PageWrapper;
|
|
|
|
export default AdminView;
|