-
Notifications
You must be signed in to change notification settings - Fork 79
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(core): add customer change password for logged-in customer #704
Conversation
🦋 Changeset detectedLatest commit: 3c9ee32 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
4 Ignored Deployments
|
49b2456
to
939ff64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing locally seems to work! However, rather than including the account settings placeholder in this PR, can we just add the code required for changing passwords to work?
The reason behind this request is because if we cut another Catalyst release with the placeholder work included, people will be creating Catalyst storefronts locally with placeholder forms and that could lead to confusion, I'd imagine.
939ff64
to
62266a4
Compare
...
Hey, Matt. Yeah, it's a fair point so I've removed |
62266a4
to
a8c154d
Compare
a8c154d
to
631ef8e
Compare
Confirmed functionality still works - but didn't have a chance to finish code review. Will finish ASAP!
if (e.target.form) { | ||
formData = new FormData(e.target.form); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have a case when we have no form
and formData is null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's a good question. e.target.form
possibly can be null
but your question brought me up to a small refactoring -I've simplified code and removed checking for FormData
is null
on a second step. Now it's done like:
if (e.target.form) {
currentPasswordValue = new FormData(e.target.form).get('current-password');
}
Thanks!
631ef8e
to
7098eff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
if (!session) { | ||
redirect('/login'); | ||
} | ||
|
||
if (action === 'reset_password') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on having this as a different page? Should help simplify change-password-form.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to create separate page alongside change-password-form
that will be used exclusively for logged-in Customers?🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To chime in on this, there is usually two flows for how to change your password:
- Update your password when logged in – has a session tied to it.
- Forgot your password as a guest – the email sent to the user will contain a redirect link with code to generate a "session" in order to validate changing the password.
Since those are two separate use-cases, I think sharing a form shouldn't be an option here, especially from a security perspective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, guys. it's updated
let newPasswordValue: FormDataEntryValue | null = null; | ||
const confirmPasswordValue = e.target.value; | ||
|
||
return setIsConfirmPasswordValid(confirmPassword === newPassword); | ||
if (e.target.form) { | ||
newPasswordValue = new FormData(e.target.form).get('new-password'); | ||
} | ||
|
||
setIsConfirmPasswordValid( | ||
confirmPasswordValue.length > 0 && newPasswordValue === confirmPasswordValue, | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the schema CustomerChangePasswordSchema
here? We can modify it to check for equality and length requirements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've refactored this part but not sure if it's for good. it looks bulkier now. What do you say?
7098eff
to
b09b8b1
Compare
b09b8b1
to
7b08e8e
Compare
7b08e8e
to
805541e
Compare
805541e
to
9a84033
Compare
7d1bdde
to
0b20ce4
Compare
}; | ||
} | ||
|
||
return { status: 'error', message: 'Unknown error' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return { status: 'error', message: 'Unknown error' }; | |
return { status: 'error', message: 'Unknown error.' }; |
}); | ||
|
||
if (response.errors.length === 0) { | ||
return { status: 'success', message: '' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return response
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a message here but we basically don't use any data.
95f9458
to
ed3124b
Compare
ed3124b
to
b28a50d
Compare
b28a50d
to
f90e97d
Compare
f90e97d
to
b09b19c
Compare
b09b19c
to
3c9ee32
Compare
⚡️🏠 Lighthouse reportLighthouse ran against https://catalyst-latest-gzpcucyzw-bigcommerce-platform.vercel.app 🖥️ DesktopWe ran Lighthouse against the changes on a desktop and produced this report. Here's the summary:
📱 MobileWe ran Lighthouse against the changes on a mobile and produced this report. Here's the summary:
|
What/Why?
This PR adds functionality for changed password if Customer is logged in.
Account settings form is a placehodler. Will be updated in separate PR.
Testing
locally