Skip to content
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

feat(DIA-899): One-Shot Google Sign-In #11036

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
replaced authGoogle call with authGoogle2
  • Loading branch information
iskounen committed Oct 29, 2024
commit db18c1b03de22ffbeff327e5635a6923357f70d9
8 changes: 1 addition & 7 deletions src/app/Scenes/Onboarding/Auth2/scenes/LoginWelcomeStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,7 @@ const SocialLoginButtons: React.FC = () => {
return GlobalStore.actions.auth.authApple({ agreedToReceiveEmails: true })
})

const handleGooglePress = () =>
onSocialLogin(() => {
return GlobalStore.actions.auth.authGoogle({
signInOrUp: mode === "login" ? "signIn" : "signUp",
agreedToReceiveEmails: mode === "signup",
})
})
const handleGooglePress = () => GlobalStore.actions.auth.authGoogle2()

const handleFacebookPress = () =>
onSocialLogin(() => {
Expand Down
13 changes: 6 additions & 7 deletions src/app/store/AuthModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export interface AuthModel {
GlobalStoreModel,
Promise<AuthPromiseResolveType>
>
authGoogle2: Thunk<this, { onSignIn?: () => void }, {}, GlobalStoreModel, Promise<SignInStatus>>
authGoogle2: Thunk<this, undefined, {}, GlobalStoreModel, Promise<SignInStatus>>
authApple: Thunk<
this,
{ agreedToReceiveEmails?: boolean; onSignIn?: () => void },
Expand Down Expand Up @@ -670,7 +670,7 @@ export const getAuthModel = (): AuthModel => ({
}
})
}),
authGoogle2: thunk(async (actions, options, store) => {
authGoogle2: thunk(async (actions, _payload, helpers) => {
let email, accessToken

try {
Expand Down Expand Up @@ -734,22 +734,21 @@ export const getAuthModel = (): AuthModel => ({
userAccessTokenExpiresIn: expires_in,
userID: user.id,
userEmail: user.email,
onboardingState: "incomplete",
// TODO: How else can I tell if the user needs to see the onboarding quiz?
onboardingState: user.completed_onboarding_at ? "complete" : "incomplete",
})

actions.identifyUser()

if (user.id !== store.getState().previousSessionUserID) {
const storeActions = store.getStoreActions()
if (user.id !== helpers.getState().previousSessionUserID) {
const storeActions = helpers.getStoreActions()

storeActions.search.clearRecentSearches()
storeActions.recentPriceRanges.clearAllPriceRanges()
}

postEventToProviders(tracks.loggedIn("google"))

options?.onSignIn?.()

// Setting up user prefs from gravity after successsfull login.
GlobalStore.actions.userPrefs.fetchRemoteUserPrefs()

Expand Down