-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefill workspace invitation email (#7174) #8826
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ import { useRecoilValue } from 'recoil'; | |
import { z } from 'zod'; | ||
|
||
import { PASSWORD_REGEX } from '@/auth/utils/passwordRegex'; | ||
import { isSignInPrefilledState } from '@/client-config/states/isSignInPrefilledState'; | ||
import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState'; | ||
import { useSearchParams } from 'react-router-dom'; | ||
import { isDefined } from '~/utils/isDefined'; | ||
|
||
export const validationSchema = z | ||
.object({ | ||
|
@@ -20,7 +22,12 @@ export const validationSchema = z | |
|
||
export type Form = z.infer<typeof validationSchema>; | ||
export const useSignInUpForm = () => { | ||
const isSignInPrefilled = useRecoilValue(isSignInPrefilledState); | ||
const isDeveloperDefaultSignInPrefilled = useRecoilValue( | ||
isDeveloperDefaultSignInPrefilledState, | ||
); | ||
const [searchParams] = useSearchParams(); | ||
const invitationPrefilledEmail = searchParams.get('email'); | ||
|
||
const form = useForm<Form>({ | ||
mode: 'onChange', | ||
defaultValues: { | ||
|
@@ -33,10 +40,12 @@ export const useSignInUpForm = () => { | |
}); | ||
|
||
useEffect(() => { | ||
if (isSignInPrefilled === true) { | ||
if (isDefined(invitationPrefilledEmail)) { | ||
form.setValue('email', invitationPrefilledEmail); | ||
} else if (isDeveloperDefaultSignInPrefilled === true) { | ||
form.setValue('email', '[email protected]'); | ||
form.setValue('password', 'Applecar2025'); | ||
} | ||
}, [form, isSignInPrefilled]); | ||
}, [form, isDeveloperDefaultSignInPrefilled, invitationPrefilledEmail]); | ||
return { form: form }; | ||
}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,7 +6,7 @@ import { chromeExtensionIdState } from '@/client-config/states/chromeExtensionId | |||||
import { clientConfigApiStatusState } from '@/client-config/states/clientConfigApiStatusState'; | ||||||
import { isAnalyticsEnabledState } from '@/client-config/states/isAnalyticsEnabledState'; | ||||||
import { isDebugModeState } from '@/client-config/states/isDebugModeState'; | ||||||
import { isSignInPrefilledState } from '@/client-config/states/isSignInPrefilledState'; | ||||||
import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState'; | ||||||
import { isSignUpDisabledState } from '@/client-config/states/isSignUpDisabledState'; | ||||||
import { sentryConfigState } from '@/client-config/states/sentryConfigState'; | ||||||
import { supportChatState } from '@/client-config/states/supportChatState'; | ||||||
|
@@ -20,7 +20,9 @@ export const ClientConfigProviderEffect = () => { | |||||
const setIsDebugMode = useSetRecoilState(isDebugModeState); | ||||||
const setIsAnalyticsEnabled = useSetRecoilState(isAnalyticsEnabledState); | ||||||
|
||||||
const setIsSignInPrefilled = useSetRecoilState(isSignInPrefilledState); | ||||||
const setisDeveloperDefaultSignInPrefilled = useSetRecoilState( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
isDeveloperDefaultSignInPrefilledState, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: camelCase naming convention not followed for 'setisDeveloperDefaultSignInPrefilled' - first word should be capitalized |
||||||
); | ||||||
const setIsSignUpDisabled = useSetRecoilState(isSignUpDisabledState); | ||||||
|
||||||
const setBilling = useSetRecoilState(billingState); | ||||||
|
@@ -76,7 +78,7 @@ export const ClientConfigProviderEffect = () => { | |||||
}); | ||||||
setIsDebugMode(data?.clientConfig.debugMode); | ||||||
setIsAnalyticsEnabled(data?.clientConfig.analyticsEnabled); | ||||||
setIsSignInPrefilled(data?.clientConfig.signInPrefilled); | ||||||
setisDeveloperDefaultSignInPrefilled(data?.clientConfig.signInPrefilled); | ||||||
FelixMalfait marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
setIsSignUpDisabled(data?.clientConfig.signUpDisabled); | ||||||
|
||||||
setBilling(data?.clientConfig.billing); | ||||||
|
@@ -99,7 +101,7 @@ export const ClientConfigProviderEffect = () => { | |||||
data, | ||||||
setAuthProviders, | ||||||
setIsDebugMode, | ||||||
setIsSignInPrefilled, | ||||||
setisDeveloperDefaultSignInPrefilled, | ||||||
setIsSignUpDisabled, | ||||||
setSupportChat, | ||||||
setBilling, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createState } from 'twenty-ui'; | ||
|
||
export const isDeveloperDefaultSignInPrefilledState = createState<boolean>({ | ||
key: 'isDeveloperDefaultSignInPrefilledState', | ||
defaultValue: false, | ||
}); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,6 +229,7 @@ export class WorkspaceInvitationService { | |
|
||
if (invitation.value.isPersonalInvitation) { | ||
link.searchParams.set('inviteToken', invitation.value.appToken.value); | ||
link.searchParams.set('email', invitation.value.email); | ||
} | ||
Comment on lines
231
to
233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Consider URL encoding the email parameter value to prevent potential URL injection issues |
||
const emailData = { | ||
link: link.toString(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: consider using object destructuring with useRecoilValue to improve readability and reduce line count