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(Password): Allow special characters in password #1402

Merged
merged 15 commits into from
Oct 22, 2023

Conversation

geoffreykwan
Copy link
Member

@geoffreykwan geoffreykwan commented Sep 5, 2023

Changes

  • Allow these symbols to be used in a password !@#$%^&*
  • Passwords now require a letter, number, symbol, and to be at least 8 characters (we no longer require uppercase letter but they may still be used)
  • Added password strength indicator
  • Added visual password requirement validator

Test

Make sure setting a password in these locations still works and validates with the new requirements

  • Create teacher account
  • Create student account
  • Forgot teacher password
  • Forgot student password
  • User change password
  • Teacher change student password

Closes #1049

Add more interactive password requirements indicator.
Add password strength indicator.

#1049
@geoffreykwan geoffreykwan marked this pull request as ready for review September 6, 2023 15:09
Copy link
Member

@hirokiterashima hirokiterashima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature works great. I have some comments/questions:

  • Do we want to require symbols? This would make passwords more difficult to remember, especially students.
  • Always showing password strength indicator by default when the pages load feels a bit off because I haven't typed in anything yet. Should it show up once you start typing a password?
  • And also maybe @breity can style the indicator a bit to fit into the page better and ensure contrast (a11y)?
  • Change success message from "Password Changed" to "Successfully changed password" to make it more friendly?
  • Code improvements

src/app/common/password-helper.ts Outdated Show resolved Hide resolved
Comment on lines 223 to 246
function generateObservableResponse(arg: string | any, isSuccess: boolean): Observable<any> {
return isSuccess ? generateSuccessObservable(arg) : generateErrorObservable(arg);
}

function generateSuccessObservable(arg: string | any): Observable<any> {
return new Observable((observer) => {
observer.next(generateSuccessResponseValue(arg));
observer.complete();
});
}

function generateSuccessResponseValue(arg: string | any): any {
return typeof arg === 'string' ? { messageCode: arg } : arg;
}

function generateErrorObservable(arg: string | any): Observable<any> {
return new Observable((observer) => {
observer.error(generateErrorResponseValue(arg));
observer.complete();
});
}

function generateErrorResponseValue(arg: string | any): any {
return typeof arg === 'string' ? { error: { messageCode: arg } } : { error: arg };
Copy link
Member

@hirokiterashima hirokiterashima Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce duplication? Do you need generateSuccessObservable() and generateErrorObservable(), or can we do it with a ternary in generateObservableResponse()?

function generateObservableResponse(arg: string | any, isSuccess: boolean): Observable<any> {
  return new Observable((observer) => {
    observer.next(isSuccess ? generateSuccessResponseValue(arg) : generateErrorResponseValue(arg));
    observer.complete();
  });
}

Copy link
Member

@hirokiterashima hirokiterashima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we try not to introduce these new duplications?

  1. generateSuccessObservable() and generateErrorObservable()
  2. setNewPassword() and setConfirmNewPassword()

Copy link
Member

@hirokiterashima hirokiterashima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New changes look good.

We still need to discuss/address these:

  • Always showing password strength indicator by default when the pages load feels a bit off because I haven't typed in anything yet. Should it show up once you start typing a password?
  • Maybe @breity can style the indicator a bit to fit with the rest of the page better and ensure that a11y standards are met (e.g. has good contrast)?

@geoffreykwan
Copy link
Member Author

@breity I needed to add this to new-password-and-confirm.component.scss in order to set the width of the menu since the default width caused some text to wrap. Is there a better way to do this without ng-deep?

::ng-deep .mat-mdc-menu-panel {
  max-width: none !important;
}

@breity
Copy link
Member

breity commented Oct 16, 2023

I removed the ng-deep requirement by setting view encapsulation to none for the component. Just need to be careful to make sure component styles don't modify any styles used elsewhere in the app when doing so.

I also cleaned up the styles/layout a bit and addressed text color contrast for a11y. I removed the changing color for the text indicating password strength ("Very Weak", "Weak", ...) because it's difficult to find colors with sufficient contrast in the yellow and orange ranges unless they're rather dark. I think the colors on the strength meter combined with text itself works fine.

@hirokiterashima hirokiterashima self-requested a review October 18, 2023 00:28
Copy link
Member

@hirokiterashima hirokiterashima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New popup behavior looks good.

Can you add margin or padding to the text in the popup? Everything looks very close to the edge of the popup, which makes it a bit hard to read:
image

@geoffreykwan geoffreykwan merged commit 5780c73 into develop Oct 22, 2023
2 checks passed
@geoffreykwan geoffreykwan deleted the issue-1049-allow-special-characters-in-password branch October 22, 2023 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow a set of special characters in passwords
3 participants