Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ app/utils/config.js
config.yml
.DS_Store
yarn.lock

.vscode
cypress/videos/**
cypress/screenshots/**
2 changes: 1 addition & 1 deletion app/pages/Auth/SignUpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const SignUpPage = () => {
We want to make sure that your account information is safe, so you
will be sent a verification code to your email each time you log in.
Please enter in your email address and then check your email to find
a 5-number verification code.
a 6 digit verification code.
</p>
<form className={styles.authForm} onSubmit={signUp}>
<input
Expand Down
15 changes: 10 additions & 5 deletions app/utils/AuthService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ export const completeUserSignup = (
name: string,
organization: string | null = null
) => {
passwordlessLogin(authClient, email, verificationCode);
// Store user sign up data, which will be saved to our backend after Auth0 success redirect
setUserSignUpData({ email, name, organization });
passwordlessLogin(authClient, email, verificationCode, {
email,
name,
organization,
});
};

/** This method initiates the log-in/sign-up process by sending a code
Expand Down Expand Up @@ -99,7 +101,8 @@ export const passwordlessStart = (authClient: WebAuth, email: string) => {
export const passwordlessLogin = (
authClient: WebAuth,
email: string,
verificationCode: string
verificationCode: string,
userSignUpData?: UserSignUpData
) => {
const stateToken = createStateToken();
sessionStorage.setItem("authStateToken", stateToken);
Expand All @@ -117,6 +120,8 @@ export const passwordlessLogin = (
}
}
);
// Store user sign up data, which will be saved to our backend after Auth0 success redirect
setUserSignUpData(userSignUpData ?? { email, name: "", organization: null });
};

export const logout = (
Expand Down Expand Up @@ -154,7 +159,7 @@ export const saveUser = (
authToken: string
) => {
return post(
"/api/users",
"/api/v2/users",
{ ...userSignUpData, user_external_id: userExternalId },
{ Authorization: `Bearer ${authToken}` }
);
Expand Down
6 changes: 3 additions & 3 deletions app/utils/useAppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ export const AppProvider = ({
// If the SessionCacher has userSignUpData object, that means a user has just been created
// in Auth0 and a redirect has occurred. Therefore, we save the new user data to our database.
// The authState must also have propagated or else we won't have the token yet.
const newUserData = SessionCacher.getUserSignUpData();
if (newUserData && authState) {
const userData = SessionCacher.getUserSignUpData();
if (userData && authState) {
SessionCacher.clearUserSignUpData();
AuthService.saveUser(
newUserData,
userData,
authState.user.externalId,
authState.accessTokenObject.token
);
Expand Down
Loading