fix: team invite broken link (#13344)

* fix: team invite broken link

* default value fix

---------

Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-01-22 15:31:57 +00:00
1 parent 3c8c6d0574
commit 559ab4192f
3 files changed
+10 -3

No files matched your search

@@ -53,7 +53,11 @@ export default function InviteLinkSettingsModal(props: InvitationLinkSettingsMod
];
}, [t]);
const linkSettingsFormMethods = useForm<LinkSettingsForm>();
const linkSettingsFormMethods = useForm<LinkSettingsForm>({
defaultValues: {
expiresInDays: props.expiresInDays,
},
});
const handleSubmit = (values: LinkSettingsForm) => {
setInviteExpirationMutation.mutate({
@@ -41,6 +41,7 @@ export const createInviteHandler = async ({ ctx, input }: CreateInviteOptions) =
identifier: `invite-link-for-teamId-${teamId}`,
token,
expires: new Date(new Date().setHours(168)), // +1 week,
expiresInDays: 7,
teamId,
},
});
@@ -29,13 +29,15 @@ export const setInviteExpirationHandler = async ({ ctx, input }: SetInviteExpira
throw new TRPCError({ code: "UNAUTHORIZED" });
const oneDay = 24 * 60 * 60 * 1000;
const expires = expiresInDays ? new Date(Date.now() + expiresInDays * oneDay) : new Date();
const expires = expiresInDays
? new Date(Date.now() + expiresInDays * oneDay)
: new Date("9999-12-31T23:59:59Z"); //maximum possible date incase the link is set to never expire
await prisma.verificationToken.update({
where: { token },
data: {
expires,
expiresInDays,
expiresInDays: expiresInDays ? expiresInDays : null,
},
});
};