-
Notifications
You must be signed in to change notification settings - Fork 214
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
O3-1409: Support for users changing passwords #902
Conversation
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.
@jnsereko This is great work in many ways! A few things:
- I think it would be preferable to have this as part of the (much neglected) openmrs-esm-admin-tools repo.
- Instead of a full page, I think the password change could be handled as a modal.
- As a modal, I think the width could be much smaller than it presently is.
|
||
return ( | ||
<> | ||
<SwitcherDivider className={styles.divider} /> |
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 don't think that the SwitcherDivider
should be part of this class.
); | ||
}; | ||
|
||
export default ChangePasswordLink; |
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.
export default ChangePasswordLink; | |
export default ChangePasswordLink; | |
padding-right: 0rem; | ||
@include brand-02(background-color); | ||
@extend .productiveHeading01; | ||
width: 16rem; |
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.
Using the Carbon $spacing
utils. I'm also not sure why you're importing ../root.scss
here?
const minLengthPassword = minLengthRegExp.test(passwordInputValue); | ||
let errMsg = ''; | ||
if (passwordLength === 0) { | ||
errMsg = 'Password is empty'; |
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.
Any display string always needs to be translatable.
{t('discard', 'Discard')} | ||
</Button> | ||
<Button | ||
style={{ maxWidth: '50%' }} |
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'd use SCSS rather than inline styles for this.
import { openmrsFetch } from '@openmrs/esm-framework'; | ||
|
||
export async function performPasswordChange(oldPassword: string, newPassword: string) { | ||
const abortController = new AbortController(); |
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.
Not much use for an AbortController inside this method. This is what useAbortController()
is for (automatically aborts requests when the UI unmounts a component).
try { | ||
setIsSavingPassword(true); | ||
const response = await performPasswordChange(passwordInput.oldPassword, passwordInput.confirmPassword); | ||
if (response.ok) { |
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 (repsonse.ok)
is redundant. openmrsFetch
throws an exception (so the Promise will throw an error) if the result isn't ok.
const response = await performPasswordChange(passwordInput.oldPassword, passwordInput.confirmPassword); | ||
if (response.ok) { | ||
performLogout().then(() => { | ||
const defaultLang = document.documentElement.getAttribute('data-default-lang'); |
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.
Uh... just redirect to the logout handler I guess... We've never forced people to re-login after changing their password though, so I'm not a huge fan of this.
thank you @ibacher for taking a look at this. |
Requirements
feat
,fix
, orchore
, among others). See existing PR titles for inspiration.For changes to apps
If applicable
Summary
O3 screen to allow users to change their password.
cc @michaelbontyes @vasharma05 @denniskigen @hadijahkyampeire
Screenshots
change.passwords.mov
Related Issue
https://openmrs.atlassian.net/browse/O3-1409
Other