Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
7f8e46f
add new check email page
yunakim714 Oct 31, 2024
1dd7f93
Merge branch 'feature-passwordless-social-login' into W-16795956-chec…
yunakim714 Nov 4, 2024
4b5a766
lint
yunakim714 Nov 4, 2024
e4523d3
Add test file
yunakim714 Nov 4, 2024
b8383f9
fix email prop
yunakim714 Nov 4, 2024
b3b1aef
hook up handlepasswordlesslogin to new ui buttons
yunakim714 Nov 6, 2024
59b4eb2
useref for submitted email
yunakim714 Nov 6, 2024
3a2bc7f
check that the email is passed and rendered
yunakim714 Nov 6, 2024
60b22fe
check that email view renders the email modal
yunakim714 Nov 6, 2024
2fc643d
disable social login by default
yunakim714 Nov 7, 2024
e667f24
remove checkemail page
yunakim714 Nov 7, 2024
5bfa864
move setcurrentview
yunakim714 Nov 7, 2024
6da68a3
update submitform logic based on login flow
yunakim714 Nov 7, 2024
4cb119e
rename component and use form
yunakim714 Nov 7, 2024
7d77678
First pass
bredmond-sf Nov 11, 2024
c4f76a2
Fix contact key and send email
bredmond-sf Nov 12, 2024
f069a4d
Move email link to external file
bredmond-sf Nov 12, 2024
6d66a18
Cache token
bredmond-sf Nov 12, 2024
3457660
Fix format
bredmond-sf Nov 12, 2024
c9cb595
make passwordless login work in auth-modal
hajinsuha1 Nov 12, 2024
fe5aecb
fix check email modal showing for password login after user has logge…
hajinsuha1 Nov 12, 2024
a18210d
create use-passwordless-login hook and support passwordless in /login…
hajinsuha1 Nov 13, 2024
2d1df55
add working passwordless login landing page!
hajinsuha1 Nov 13, 2024
acf5410
add reset-password-landing page
hajinsuha1 Nov 13, 2024
f5f7816
Revert "add reset-password-landing page"
hajinsuha1 Nov 13, 2024
c459a5c
get callback_uri from default.js
hajinsuha1 Nov 15, 2024
6e9d4ab
Merge branch 'feature-passwordless-social-login' into W-17093012-pass…
hajinsuha1 Nov 15, 2024
9e02121
revert default.js to use client c9c45bfd
hajinsuha1 Nov 15, 2024
2094575
Merge branch 'develop' of github.com:SalesforceCommerceCloud/pwa-kit …
bredmond-sf Nov 19, 2024
e30c985
add unit test for use-passwordless-login.js
hajinsuha1 Nov 19, 2024
fea3716
Merge branch 'W-17093012-passwordless-poc-mc' of github.com:Salesforc…
hajinsuha1 Nov 19, 2024
bfc543b
display better error message for 401 from /oauth2/passwordless/token API
hajinsuha1 Nov 19, 2024
06377fd
call mergeBasket during passwordless login
hajinsuha1 Nov 19, 2024
65932e2
use private client in default.js
hajinsuha1 Nov 20, 2024
f768507
Merge branch 'feature-passwordless-social-login' into W-17093012-pass…
hajinsuha1 Nov 21, 2024
6d578f0
fix error after logging in + merge basket impl WIPd
hajinsuha1 Nov 21, 2024
03e0b08
use authotizePasswordless from AuthHelpers
hajinsuha1 Nov 22, 2024
b9408ed
pass a path for callbackURI
hajinsuha1 Nov 22, 2024
5dd3218
Add test for post endpoints
bredmond-sf Nov 22, 2024
9cba398
make merge basket work for passwordless login
hajinsuha1 Nov 22, 2024
93ffca3
Merge branch 'W-17093012-passwordless-poc-mc' of github.com:Salesforc…
hajinsuha1 Nov 22, 2024
8a6a779
fix errors in ssr.js
hajinsuha1 Nov 22, 2024
6c5beb2
fix ssr.js by always importing marketing-cloud-email-link
hajinsuha1 Nov 22, 2024
03047f8
update use-passwordless-login test
hajinsuha1 Nov 22, 2024
d90eaa4
lint and create marketing-cloud folder
yunakim714 Dec 3, 2024
2c9565e
remove enable_ssr_post
yunakim714 Dec 5, 2024
1b90e44
cleanup
yunakim714 Dec 5, 2024
984a36c
Merge branch 'feature-passwordless-social-login' into W-17093012-pass…
yunakim714 Dec 11, 2024
9fa1fbd
add comments for marketing-cloud-email-link.js
hajinsuha1 Dec 16, 2024
8042db8
renmae callbackURI to passwordlessLoginCallbackURI
hajinsuha1 Dec 18, 2024
12feb9e
create a function for handlePasswordlessLogin
hajinsuha1 Dec 18, 2024
83656b9
remove use-passwordless-login hooks
hajinsuha1 Dec 18, 2024
6c33000
@W-15953350 Reset Password (#2132)
hajinsuha1 Dec 18, 2024
073154e
create PASSWORDLESS_LOGIN_LANDING_PATH in constants
hajinsuha1 Dec 19, 2024
0fbb136
remove getting callbackURI from config in commerce-sdk-react/src/auth
hajinsuha1 Dec 19, 2024
e4413ca
update default.js to use working SLAS private client
hajinsuha1 Dec 19, 2024
00db78f
add sendMagicLinkEmail function in ssr.js
hajinsuha1 Dec 23, 2024
2a56b20
update marketing-cloud-email-link.js to use built-in fetch
hajinsuha1 Dec 23, 2024
c10a9fa
add warning if marketing cloud env vars are not set
hajinsuha1 Dec 23, 2024
7b46eb8
lint
hajinsuha1 Dec 23, 2024
8f78ea8
update marketing-cloud-email-link unit test
hajinsuha1 Dec 23, 2024
b1f717a
fix white screen when submitting passwordless email
hajinsuha1 Dec 23, 2024
4916285
announce content in email confirmation dialog
hajinsuha1 Dec 26, 2024
322dea2
revert default.js changes
hajinsuha1 Dec 26, 2024
efe0d1b
remove enabling private client from template retail react app _app_co…
hajinsuha1 Dec 27, 2024
a3d7117
initial implementation of checkout passwordless login
hajinsuha1 Dec 30, 2024
34c7177
reset isPasswordlessLoginClicked after authorizePasswordlessLogin API…
hajinsuha1 Dec 30, 2024
738aa9f
Merge branch 'feature-passwordless-social-login' into W-17271709-pass…
hajinsuha1 Dec 30, 2024
2e2994d
use constant for auth modal view values
hajinsuha1 Dec 30, 2024
a9ac1ca
add unit tests for LoginState
hajinsuha1 Dec 30, 2024
5119614
reword "Checkout as Guest" to "Back to Sign In Options"
hajinsuha1 Dec 31, 2024
669568c
allow lower case for idp names
hajinsuha1 Jan 2, 2025
7b5e450
don't save guest when passwordless login is clicked
hajinsuha1 Jan 2, 2025
b9b51d8
add unit tests for ContactInfo
hajinsuha1 Jan 2, 2025
af4ceb2
lint
hajinsuha1 Jan 2, 2025
8dfbd13
translations
hajinsuha1 Jan 2, 2025
5e6141d
remove todo
hajinsuha1 Jan 2, 2025
692f0e9
fix initialEmail not getting set in auth modal
hajinsuha1 Jan 3, 2025
c536635
fix typo in comments
hajinsuha1 Jan 6, 2025
b7cfad0
handle error states for reset password and social login
yunakim714 Jan 6, 2025
3857c96
add error handling for authorize passwordless
yunakim714 Jan 6, 2025
60726cc
add error handling of passwordless
yunakim714 Jan 7, 2025
865765c
add error handling for authorize idp
yunakim714 Jan 7, 2025
480a5f3
check error status for message
yunakim714 Jan 7, 2025
37f19c0
resolve double click bug
yunakim714 Jan 7, 2025
dd8f3e9
handle async login in useeffect correctly
yunakim714 Jan 7, 2025
4917ef3
check for invalid token error in passwordless login
yunakim714 Jan 7, 2025
2531c5c
handle invalid token error for reset password
yunakim714 Jan 7, 2025
05eabf9
fix profile tests
yunakim714 Jan 7, 2025
56b3de5
fix social login tests
yunakim714 Jan 7, 2025
79116bb
fix login form tests
yunakim714 Jan 7, 2025
812b92b
fix passwordless component tests
yunakim714 Jan 7, 2025
04e21fa
fix account tests
yunakim714 Jan 7, 2025
5f0c2da
Merge branch 'W-17458039-handle-error-states' into W-17271709-passwor…
hajinsuha1 Jan 9, 2025
ee5e599
update error message for passwordless login error
yunakim714 Jan 10, 2025
b13835d
move error message to constants
yunakim714 Jan 10, 2025
ba3d8f4
add error message translations
yunakim714 Jan 13, 2025
ca22bef
Merge branch 'W-17458039-handle-error-states' into W-17271709-passwor…
hajinsuha1 Jan 14, 2025
56b3b1a
update error handling for authorizePasswordless
hajinsuha1 Jan 14, 2025
8316458
check if reset password callback is an absolute url
yunakim714 Jan 14, 2025
76cb121
Merge branch 'W-17458039-handle-error-states' into W-17271709-passwor…
hajinsuha1 Jan 14, 2025
d0344b6
throw error in sdk
yunakim714 Jan 14, 2025
95bea67
lint
yunakim714 Jan 14, 2025
c555280
lint
yunakim714 Jan 14, 2025
e9e5dcf
Merge branch 'W-17458039-handle-error-states' into W-17271709-passwor…
hajinsuha1 Jan 15, 2025
5107f31
remove checking status and throwing error in handlePasswordlessLogin …
hajinsuha1 Jan 15, 2025
7960548
ensure Check Email modal doesn't open on error and password login wor…
hajinsuha1 Jan 15, 2025
30ea366
update error handling for user not found
yunakim714 Jan 21, 2025
7f2c142
move user not found to constants
yunakim714 Jan 21, 2025
0c5cbfd
Merge branch 'W-17458039-handle-error-states' into W-17271709-passwor…
hajinsuha1 Jan 21, 2025
306bf87
Merge branch 'feature-passwordless-social-login' into W-17458039-hand…
yunakim714 Jan 21, 2025
fabda07
update contact info passwordless login error message handling
hajinsuha1 Jan 21, 2025
b659bfc
Merge branch 'W-17458039-handle-error-states' into W-17271709-passwor…
hajinsuha1 Jan 21, 2025
f9abaa7
Merge branch 'W-17271709-passwordless-login-in-checkout' of github.co…
hajinsuha1 Jan 21, 2025
9d7e556
fix account test
yunakim714 Jan 22, 2025
dde5352
Merge branch 'W-17458039-handle-error-states' of github.com:Salesforc…
yunakim714 Jan 22, 2025
e0cb754
revert change
yunakim714 Jan 22, 2025
c83457a
Merge branch 'W-17458039-handle-error-states' into W-17271709-passwor…
hajinsuha1 Jan 22, 2025
f6e3623
Merge branch 'feature-passwordless-social-login' into W-17271709-pass…
hajinsuha1 Jan 22, 2025
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
16 changes: 11 additions & 5 deletions packages/template-retail-react-app/app/hooks/use-auth-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ import {usePasswordReset} from '@salesforce/retail-react-app/app/hooks/use-passw
import {isServer} from '@salesforce/retail-react-app/app/utils/utils'
import {getConfig} from '@salesforce/pwa-kit-runtime/utils/ssr-config'

const LOGIN_VIEW = 'login'
const REGISTER_VIEW = 'register'
const PASSWORD_VIEW = 'password'
const EMAIL_VIEW = 'email'
export const LOGIN_VIEW = 'login'
export const REGISTER_VIEW = 'register'
export const PASSWORD_VIEW = 'password'
export const EMAIL_VIEW = 'email'

const LOGIN_ERROR = defineMessage({
defaultMessage: "Something's not right with your email or password. Try again.",
Expand All @@ -57,6 +57,7 @@ const LOGIN_ERROR = defineMessage({

export const AuthModal = ({
initialView = LOGIN_VIEW,
initialEmail = '',
onLoginSuccess = noop,
onRegistrationSuccess = noop,
isOpen,
Expand Down Expand Up @@ -85,7 +86,7 @@ export const AuthModal = ({
const register = useAuthHelper(AuthHelpers.Register)

const [loginType, setLoginType] = useState(LOGIN_TYPES.PASSWORD)
const [passwordlessLoginEmail, setPasswordlessLoginEmail] = useState('')
const [passwordlessLoginEmail, setPasswordlessLoginEmail] = useState(initialEmail)
const {getPasswordResetToken} = usePasswordReset()
const authorizePasswordlessLogin = useAuthHelper(AuthHelpers.AuthorizePasswordless)

Expand Down Expand Up @@ -216,6 +217,10 @@ export const AuthModal = ({
form.reset()
}, [currentView])

useEffect(() => {
setPasswordlessLoginEmail(initialEmail)
}, [initialEmail])

useEffect(() => {
// Lets determine if the user has either logged in, or registed.
const loggingIn = currentView === LOGIN_VIEW
Expand Down Expand Up @@ -327,6 +332,7 @@ export const AuthModal = ({

AuthModal.propTypes = {
initialView: PropTypes.oneOf([LOGIN_VIEW, REGISTER_VIEW, PASSWORD_VIEW, EMAIL_VIEW]),
initialEmail: PropTypes.string,
isOpen: PropTypes.bool.isRequired,
onOpen: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,32 @@ import {
} from '@salesforce/retail-react-app/app/components/toggle-card'
import Field from '@salesforce/retail-react-app/app/components/field'
import LoginState from '@salesforce/retail-react-app/app/pages/checkout/partials/login-state'
import {AuthModal, useAuthModal} from '@salesforce/retail-react-app/app/hooks/use-auth-modal'
import {
AuthModal,
EMAIL_VIEW,
PASSWORD_VIEW,
useAuthModal
} from '@salesforce/retail-react-app/app/hooks/use-auth-modal'
import useNavigation from '@salesforce/retail-react-app/app/hooks/use-navigation'
import {useCurrentCustomer} from '@salesforce/retail-react-app/app/hooks/use-current-customer'
import {useCurrentBasket} from '@salesforce/retail-react-app/app/hooks/use-current-basket'
import {AuthHelpers, useAuthHelper, useShopperBasketsMutation} from '@salesforce/commerce-sdk-react'
import {
API_ERROR_MESSAGE,
FEATURE_UNAVAILABLE_ERROR_MESSAGE,
CREATE_ACCOUNT_FIRST_ERROR_MESSAGE,
PASSWORDLESS_ERROR_MESSAGES,
USER_NOT_FOUND_ERROR
} from '@salesforce/retail-react-app/app/constants'

const ContactInfo = ({isSocialEnabled = false, isPasswordlessEnabled = false, idps = []}) => {
const {formatMessage} = useIntl()
const authModal = useAuthModal('password')
const navigate = useNavigation()
const {data: customer} = useCurrentCustomer()
const {data: basket} = useCurrentBasket()
const login = useAuthHelper(AuthHelpers.LoginRegisteredUserB2C)
const logout = useAuthHelper(AuthHelpers.Logout)
const authorizePasswordlessLogin = useAuthHelper(AuthHelpers.AuthorizePasswordless)
const updateCustomerForBasket = useShopperBasketsMutation('updateCustomerForBasket')
const mergeBasket = useShopperBasketsMutation('mergeBasket')

Expand All @@ -62,8 +74,32 @@ const ContactInfo = ({isSocialEnabled = false, isPasswordlessEnabled = false, id
const [showPasswordField, setShowPasswordField] = useState(false)
const [signOutConfirmDialogIsOpen, setSignOutConfirmDialogIsOpen] = useState(false)

const [authModalView, setAuthModalView] = useState(PASSWORD_VIEW)
const authModal = useAuthModal(authModalView)
const [isPasswordlessLoginClicked, setIsPasswordlessLoginClicked] = useState(false)

const handlePasswordlessLogin = async (email) => {
try {
await authorizePasswordlessLogin.mutateAsync({userid: email})
setAuthModalView(EMAIL_VIEW)
authModal.onOpen()
} catch (error) {
const message = USER_NOT_FOUND_ERROR.test(error.message)
? formatMessage(CREATE_ACCOUNT_FIRST_ERROR_MESSAGE)
: PASSWORDLESS_ERROR_MESSAGES.some((msg) => msg.test(error.message))
? formatMessage(FEATURE_UNAVAILABLE_ERROR_MESSAGE)
: formatMessage(API_ERROR_MESSAGE)
setError(message)
}
}

const submitForm = async (data) => {
setError(null)
if (isPasswordlessLoginClicked) {
handlePasswordlessLogin(data.email)
setIsPasswordlessLoginClicked(false)
return
}
try {
if (!data.password) {
await updateCustomerForBasket.mutateAsync({
Expand Down Expand Up @@ -108,6 +144,7 @@ const ContactInfo = ({isSocialEnabled = false, isPasswordlessEnabled = false, id
}

const onForgotPasswordClick = () => {
setAuthModalView(PASSWORD_VIEW)
authModal.onOpen()
}

Expand All @@ -117,6 +154,10 @@ const ContactInfo = ({isSocialEnabled = false, isPasswordlessEnabled = false, id
}
}, [showPasswordField])

const onPasswordlessLoginClick = async () => {
setIsPasswordlessLoginClicked(true)
}

return (
<ToggleCard
id="step-0"
Expand Down Expand Up @@ -198,12 +239,13 @@ const ContactInfo = ({isSocialEnabled = false, isPasswordlessEnabled = false, id
idps={idps}
showPasswordField={showPasswordField}
togglePasswordField={togglePasswordField}
handlePasswordlessLoginClick={onPasswordlessLoginClick}
/>
</Stack>
</Stack>
</form>
</Container>
<AuthModal {...authModal} />
<AuthModal {...authModal} initialEmail={form.getValues().email} />
</ToggleCardEdit>
<ToggleCardSummary>
<Text>{basket?.customerInfo?.email || customer?.email}</Text>
Expand Down
Loading
Loading