Invite prefill email (#43)

* Add prepopulation of email field in sign-up form
* Updated packages
This commit is contained in:
Giancarlo Buomprisco
2024-07-11 13:59:14 +08:00
committed by GitHub
parent 4f0e6b9bbb
commit 21f42f14ce
24 changed files with 151 additions and 85 deletions

View File

@@ -29,7 +29,7 @@
"@supabase/gotrue-js": "2.64.3",
"@supabase/ssr": "^0.4.0",
"@supabase/supabase-js": "^2.44.3",
"@tanstack/react-query": "5.50.1",
"@tanstack/react-query": "5.51.1",
"@types/react": "^18.3.3",
"next": "14.2.5",
"react": "18.3.1",

View File

@@ -87,6 +87,12 @@ class AuthCallbackService {
// correct page.
url.pathname = params.joinTeamPath;
searchParams.set('invite_token', inviteToken);
const emailParam = callbackUrl?.searchParams.get('email');
if (emailParam) {
searchParams.set('email', emailParam);
}
}
if (token_hash && type) {
@@ -138,7 +144,14 @@ class AuthCallbackService {
// to join a team and we want to make sure they are redirected to the
// correct page.
if (inviteToken) {
nextUrl = `${params.joinTeamPath}?invite_token=${inviteToken}`;
const emailParam = searchParams.get('email');
const urlParams = new URLSearchParams({
invite_token: inviteToken,
email: emailParam ?? ''
});
nextUrl = `${params.joinTeamPath}?${urlParams.toString()}`;
}
if (authCode) {