feat: tracking and displaying last used login method (#16356)
This commit is contained in:
1 parent
6529b49c3c
commit
2fb4289798
4 files changed
+53
-7
No files matched your search
@@ -4,6 +4,7 @@ import { useFormContext } from "react-hook-form";
|
||||
import z from "zod";
|
||||
|
||||
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
|
||||
import { useLastUsed, LastUsed } from "@calcom/lib/hooks/useLastUsed";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui";
|
||||
@@ -21,10 +22,14 @@ const schema = z.object({
|
||||
export function SAMLLogin({ samlTenantID, samlProductID, setErrorMessage }: Props) {
|
||||
const { t } = useLocale();
|
||||
const methods = useFormContext();
|
||||
const [lastUsed, setLastUsed] = useLastUsed();
|
||||
|
||||
const mutation = trpc.viewer.public.samlTenantProduct.useMutation({
|
||||
onSuccess: async (data) => {
|
||||
await signIn("saml", {}, { tenant: data.tenant, product: data.product });
|
||||
const res = await signIn("saml", {}, { tenant: data.tenant, product: data.product });
|
||||
if (res && !res.error) {
|
||||
setLastUsed("saml");
|
||||
}
|
||||
},
|
||||
onError: (err) => {
|
||||
setErrorMessage(t(err.message));
|
||||
@@ -62,7 +67,8 @@ export function SAMLLogin({ samlTenantID, samlProductID, setErrorMessage }: Prop
|
||||
email,
|
||||
});
|
||||
}}>
|
||||
{t("signin_with_saml_oidc")}
|
||||
<span>{t("signin_with_saml_oidc")}</span>
|
||||
{lastUsed === "saml" && <LastUsed />}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user