From 440f598de83b5319e8b7173a6e41780d80d67ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:39:48 +0200 Subject: [PATCH] feat(dashboard, user): prefill invite email (#9016) **What** - store invite email on the JWT invite token - prefill email in the invite form --- RESOLVES CC-125 --- packages/admin/dashboard/src/routes/invite/invite.tsx | 4 +++- packages/modules/user/src/services/user-module.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/admin/dashboard/src/routes/invite/invite.tsx b/packages/admin/dashboard/src/routes/invite/invite.tsx index 0333705314..84f6048760 100644 --- a/packages/admin/dashboard/src/routes/invite/invite.tsx +++ b/packages/admin/dashboard/src/routes/invite/invite.tsx @@ -38,6 +38,7 @@ type DecodedInvite = { jti: any exp: string iat: number + email: string } export const Invite = () => { @@ -185,6 +186,7 @@ const InvalidView = () => { const CreateView = ({ onSuccess, token, + invite, }: { onSuccess: () => void token: string @@ -196,7 +198,7 @@ const CreateView = ({ const form = useForm>({ resolver: zodResolver(CreateAccountSchema), defaultValues: { - email: "", + email: invite.email || "", first_name: "", last_name: "", password: "", diff --git a/packages/modules/user/src/services/user-module.ts b/packages/modules/user/src/services/user-module.ts index 79c9dd7b52..09c6ac5862 100644 --- a/packages/modules/user/src/services/user-module.ts +++ b/packages/modules/user/src/services/user-module.ts @@ -157,7 +157,7 @@ export default class UserModuleService expires_at: new Date().setMilliseconds( new Date().getMilliseconds() + this.config.expiresIn ), - token: this.generateToken({ id: invite.id }), + token: this.generateToken({ id: invite.id, email: invite.email }), } }) @@ -316,7 +316,7 @@ export default class UserModuleService expires_at: new Date().setMilliseconds( new Date().getMilliseconds() + this.config.expiresIn ), - token: this.generateToken({ id: invite.id }), + token: this.generateToken({ id: invite.id, email: invite.email }), } })