From 1c400c6dfc7df59d4fa0233495dc706fa60e8622 Mon Sep 17 00:00:00 2001 From: Amy Corson <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Thu, 9 Oct 2025 12:25:12 -0500 Subject: [PATCH 1/2] Fix user update before consents to terms --- lib/actions/user.js | 6 +++--- lib/util/user.js | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/actions/user.js b/lib/actions/user.js index d3ac3929f..053f76b37 100644 --- a/lib/actions/user.js +++ b/lib/actions/user.js @@ -10,10 +10,10 @@ import { convertToPlace, getPersistenceMode, isHomeOrWork, - isNewUser, positionHomeAndWorkFirst, setAtLeastNoMobilityDevice, - tidyRecentSearches + tidyRecentSearches, + userExistsInDatabase } from '../util/user' import { formattedToastSuccessMessage, @@ -391,7 +391,7 @@ export function createOrUpdateUser(userData, intl) { ) // Determine URL and method to use. - const isCreatingUser = isNewUser(loggedInUser) + const isCreatingUser = userExistsInDatabase(loggedInUser) if (isCreatingUser) { requestUrl = `${apiBaseUrl}${API_OTPUSER_PATH}` method = 'POST' diff --git a/lib/util/user.js b/lib/util/user.js index 3feeb8286..ffdb3e789 100644 --- a/lib/util/user.js +++ b/lib/util/user.js @@ -22,6 +22,10 @@ export function isNewUser(loggedInUser) { return !loggedInUser.hasConsentedToTerms } +export function userExistsInDatabase(loggedInUser) { + return !loggedInUser.id +} + // Helper functions to determine if // a location is home or work. export const isHome = (loc) => loc.type === 'home' From aba5b28ec1131d91d235ab0a752bf63639e9058c Mon Sep 17 00:00:00 2001 From: Amy Corson <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 13 Oct 2025 11:03:47 -0500 Subject: [PATCH 2/2] Fix incorrectly named variable and fix bug --- lib/actions/ui.js | 3 ++- lib/actions/user.js | 2 +- lib/util/user.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/actions/ui.js b/lib/actions/ui.js index f31a4307b..2079bb989 100644 --- a/lib/actions/ui.js +++ b/lib/actions/ui.js @@ -18,6 +18,7 @@ import { } from '../util/ui' import { getModesForActiveAgencyFilter, getUiUrlParams } from '../util/state' import { loadLocaleData } from '../util/i18n-loader' +import { userExistsInDatabase } from '../util/user' import { clearActiveSearch, @@ -468,7 +469,7 @@ export function setLocale(locale, isUpdatingLocale = false) { window.localStorage.setItem('lang', matchedLocale) - if (loggedInUser) { + if (userExistsInDatabase(loggedInUser)) { loggedInUser.preferredLocale = matchedLocale await dispatch(createOrUpdateUser(loggedInUser)) } diff --git a/lib/actions/user.js b/lib/actions/user.js index 053f76b37..4e418ddba 100644 --- a/lib/actions/user.js +++ b/lib/actions/user.js @@ -391,7 +391,7 @@ export function createOrUpdateUser(userData, intl) { ) // Determine URL and method to use. - const isCreatingUser = userExistsInDatabase(loggedInUser) + const isCreatingUser = !userExistsInDatabase(loggedInUser) if (isCreatingUser) { requestUrl = `${apiBaseUrl}${API_OTPUSER_PATH}` method = 'POST' diff --git a/lib/util/user.js b/lib/util/user.js index ffdb3e789..ba249c89a 100644 --- a/lib/util/user.js +++ b/lib/util/user.js @@ -23,7 +23,7 @@ export function isNewUser(loggedInUser) { } export function userExistsInDatabase(loggedInUser) { - return !loggedInUser.id + return loggedInUser?.id } // Helper functions to determine if