Skip to content

Commit 83e315a

Browse files
authored
feat: add first login flag (#8161)
1 parent b15bdd5 commit 83e315a

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

src/components/AuthenticationFlow/EmailLoginForm.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ export function EmailLoginForm(props: EmailLoginFormProps) {
3838

3939
const currentLocation = window.location.href;
4040
const url = new URL(currentLocation, window.location.origin);
41-
if (response?.isNewUser) {
42-
url.searchParams.set(FIRST_LOGIN_PARAM, '1');
43-
}
41+
url.searchParams.set(FIRST_LOGIN_PARAM, response?.isNewUser ? '1' : '0');
4442
window.location.href = url.toString();
4543
return;
4644
}

src/components/AuthenticationFlow/GitHubButton.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ export function GitHubButton(props: GitHubButtonProps) {
8181
localStorage.removeItem(GITHUB_LAST_PAGE);
8282
setAuthToken(response.token);
8383

84-
if (response?.isNewUser) {
85-
redirectUrl.searchParams.set(FIRST_LOGIN_PARAM, '1');
86-
}
84+
redirectUrl.searchParams.set(
85+
FIRST_LOGIN_PARAM,
86+
response?.isNewUser ? '1' : '0',
87+
);
8788

8889
const shouldTriggerPurchase =
8990
localStorage.getItem(CHECKOUT_AFTER_LOGIN_KEY) !== '0';

src/components/AuthenticationFlow/GoogleButton.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ export function GoogleButton(props: GoogleButtonProps) {
8181
redirectUrl = new URL(authRedirectUrl, window.location.origin);
8282
}
8383

84-
if (response?.isNewUser) {
85-
redirectUrl.searchParams.set(FIRST_LOGIN_PARAM, '1');
86-
}
84+
redirectUrl.searchParams.set(
85+
FIRST_LOGIN_PARAM,
86+
response?.isNewUser ? '1' : '0',
87+
);
8788

8889
const shouldTriggerPurchase =
8990
localStorage.getItem(CHECKOUT_AFTER_LOGIN_KEY) !== '0';

src/components/AuthenticationFlow/LinkedInButton.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ export function LinkedInButton(props: LinkedInButtonProps) {
8181
redirectUrl = new URL(authRedirectUrl, window.location.origin);
8282
}
8383

84-
if (response?.isNewUser) {
85-
redirectUrl.searchParams.set(FIRST_LOGIN_PARAM, '1');
86-
}
84+
redirectUrl.searchParams.set(
85+
FIRST_LOGIN_PARAM,
86+
response?.isNewUser ? '1' : '0',
87+
);
8788

8889
const shouldTriggerPurchase =
8990
localStorage.getItem(CHECKOUT_AFTER_LOGIN_KEY) !== '0';

src/components/AuthenticationFlow/TriggerVerifyAccount.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { useEffect, useState } from 'react';
22
import Cookies from 'js-cookie';
33
import { httpPost } from '../../lib/http';
4-
import { FIRST_LOGIN_PARAM, TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt';
4+
import {
5+
FIRST_LOGIN_PARAM,
6+
TOKEN_COOKIE_NAME,
7+
setAuthToken,
8+
} from '../../lib/jwt';
59
import { Spinner } from '../ReactIcons/Spinner';
610
import { ErrorIcon2 } from '../ReactIcons/ErrorIcon2';
711
import { triggerUtmRegistration } from '../../lib/browser.ts';
@@ -32,9 +36,10 @@ export function TriggerVerifyAccount() {
3236
setAuthToken(response.token);
3337

3438
const url = new URL('/', window.location.origin);
35-
if (response?.isNewUser) {
36-
url.searchParams.set(FIRST_LOGIN_PARAM, '1');
37-
}
39+
url.searchParams.set(
40+
FIRST_LOGIN_PARAM,
41+
response?.isNewUser ? '1' : '0',
42+
);
3843
window.location.href = url.toString();
3944
})
4045
.catch((err) => {

0 commit comments

Comments
 (0)