-
Notifications
You must be signed in to change notification settings - Fork 344
Add password requirements to login page #103
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
Merged
kodiakhq
merged 11 commits into
hyperdxio:main
from
jaggederest:jag/password_requirements
Nov 18, 2023
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d5c3ea7
Add password requirements to login page
jaggederest a547b5a
Merge branch 'main' into jag/password_requirements
jaggederest b8449bc
Rough draft of auto-changing password rules
jaggederest a602773
Merge remote-tracking branch 'mine/jag/password_requirements' into ja…
jaggederest a3d3573
Merge branch 'main' into jag/password_requirements
jaggederest 5369840
password validation style tweaks and cleanup
jaggederest 737964d
Merge remote-tracking branch 'mine/jag/password_requirements' into ja…
jaggederest 2a130a5
Password Check: replace SVG with html icon
jaggederest 64fd300
Expand margin below confirm password input
jaggederest efbca8a
Merge remote-tracking branch 'origin/main' into jag/password_requirem…
jaggederest 3c22f8d
Tweak password check to use form watcher and eliminate unordered list
jaggederest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { useMemo } from 'react'; | ||
|
|
||
| const checkLength = (password: string) => password.length >= 12; | ||
| const checkOneUpper = (password: string) => /[A-Z]+/.test(password); | ||
| const checkOneLower = (password: string) => /[a-z]+/.test(password); | ||
| const checkOneNumber = (password: string) => /\d+/.test(password); | ||
| const checkOneSpecial = (password: string) => /\W+/.test(password); | ||
|
|
||
| export const PasswordCheck = (password: string | null) => { | ||
| password = password ?? ''; | ||
| return ( | ||
| <ul> | ||
| <li> | ||
jaggederest marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <CheckOrX handler={checkLength} password={password}> | ||
| minimum 12 characters | ||
| </CheckOrX> | ||
| </li> | ||
| <li> | ||
| <CheckOrX handler={checkOneUpper} password={password}> | ||
| at least 1 uppercase | ||
| </CheckOrX> | ||
| </li> | ||
| <li> | ||
| <CheckOrX handler={checkOneLower} password={password}> | ||
| at least 1 lowercase | ||
| </CheckOrX> | ||
| </li> | ||
| <li> | ||
| <CheckOrX handler={checkOneNumber} password={password}> | ||
| at least 1 number | ||
| </CheckOrX> | ||
| </li> | ||
| <li> | ||
| <CheckOrX handler={checkOneSpecial} password={password}> | ||
| at least 1 special character | ||
| </CheckOrX> | ||
| </li> | ||
| </ul> | ||
| ); | ||
| }; | ||
|
|
||
| export const CheckOrX = ({ | ||
| handler, | ||
| password, | ||
| children, | ||
| }: { | ||
| handler: (password: string) => boolean; | ||
| password: string | { password: string | null }; | ||
| children: React.ReactNode; | ||
| }) => { | ||
| let actualPassword = ''; | ||
| if (typeof password === 'string') { | ||
| actualPassword = password; | ||
| } else { | ||
| actualPassword = password.password ?? ''; | ||
| } | ||
| const isValid = useMemo( | ||
| () => handler(actualPassword), | ||
| [handler, actualPassword], | ||
| ); | ||
| return ( | ||
| <span className={isValid ? 'text-success' : 'text-danger'}> | ||
| {isValid ? <Check /> : <XShape />} {children} | ||
| </span> | ||
| ); | ||
| }; | ||
|
|
||
| const Check = () => <i className={'bi bi-check2'}></i>; | ||
|
|
||
| const XShape = () => <i className={'bi bi-x'}></i>; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.