-
Notifications
You must be signed in to change notification settings - Fork 0
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
(chore): Fixed the problem where Regex would not accept - and . symbols #4
Conversation
In the pull-request i fixed the problem of the password field telling Password must be at least 8 characters, include an uppercase letter, a number, and a special character. when using a - or a . in the password like for example tEsT-Sc1bBl!e$ab
… . symbols" This reverts commit 907a421.
In the pull-request i fixed the problem of the password field telling Password must be at least 8 characters, include an uppercase letter, a number, and a special character. when using a - or a . in the password like for example tEsT-Sc1bBl!e$ab
WalkthroughThe changes involve an update to the password validation logic in the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
src/app/auth/page.tsx (1)
73-73
: LGTM! Consider improving regex readabilityThe updated regex correctly allows "-", "_", and "." symbols while maintaining strong password requirements.
Consider these improvements:
- Extract the regex to a named constant for better maintainability
- Add a comment explaining the pattern components
+ // Regex components: + // (?=.*[A-Z]) - at least one uppercase letter + // (?=.*\d) - at least one digit + // (?=.*[@$!%*?&\-_\.]) - at least one special character + // [A-Za-z\d@$!%*?&\-_\.]{8,} - allowed characters with minimum length of 8 + const PASSWORD_VALIDATION_REGEX = /^(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&\-_.])[A-Za-z\d@$!%*?&\-_\.]{8,}$/; const validatePassword = (value: string) => { - const passwordRegex = /^(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&\-_.])[A-Za-z\d@$!%*?&\-_\.]{8,}$/; + const passwordRegex = PASSWORD_VALIDATION_REGEX;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/app/auth/page.tsx
(1 hunks)
🔇 Additional comments (2)
src/app/auth/page.tsx (2)
79-79
: Formatting change looks good
73-79
: Verify consistent password validation across the codebase
Let's ensure this password validation pattern is consistently applied across all authentication-related code.
✅ Verification successful
Let me try a different approach to search for password validation patterns and authentication-related files.
Let me try one more search with a simpler pattern to find password validation logic.
Password validation is correctly implemented in a single location
The password validation is centralized in the auth page component and is consistently used for both initial validation and re-validation. The regex pattern enforces strong password requirements, and there are no conflicting implementations across the codebase. The validation is properly scoped to the authentication flow.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other password validation patterns that might need updating
rg -l 'password.*regex|regex.*password' --type ts --type tsx
# Look for other authentication-related files that might need review
fd -e ts -e tsx -E "*.test.*" -E "*.spec.*" | rg -l "auth|login|signup|register"
Length of output: 181
Script:
#!/bin/bash
# Search for password validation patterns using ripgrep
rg "(?=.*[A-Z]).*(?=.*\d).*(?=.*[@$!%*?&])" --type-add 'tsx:*.tsx' --type-add 'ts:*.ts'
# Find authentication-related files
find . -type f \( -name "*.ts" -o -name "*.tsx" \) -not -name "*.test.*" -not -name "*.spec.*" | xargs rg -l "auth|login|signup|register"
Length of output: 794
Script:
#!/bin/bash
# Check content of auth-related files for password validation
rg -A 5 "password.*=" ./src/lib/models/auth.ts ./src/app/auth/page.tsx
# Look for any password-related validation or regex patterns
rg "password.*test|validatePassword" ./src/lib/models/auth.ts ./src/app/auth/page.tsx
Length of output: 1738
@@ -70,13 +70,13 @@ function AuthContent({ router }: AuthContentProps) { | |||
|
|||
const validatePassword = (value: string) => { | |||
const passwordRegex = | |||
/^(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/; | |||
/^(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&\-_.])[A-Za-z\d@$!%*?&\-_\.]{8,}$/; | |||
setPasswordError( | |||
passwordRegex.test(value) |
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.
@kilianbalaguer Maybe a new error message informing about invalid chars would be nice
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.
YES I WILL MY KING @N3v1
Deploying scribblelabapp with Cloudflare Pages
|
@kilianbalaguer Will you be able to complete this task within this week? |
Nevio do you mean the message for unsupported character and update the other message to show the supported ones? |
See Discord 🙂 |
@kilianbalaguer Any plan on resolving the issues? 🙂 |
In the pull-request i fixed the problem of the password field telling Password must be at least 8 characters, include an uppercase letter, a number, and a special character. when using a - or a . in the password like for example tEsT-Sc1bBl!e$ab
Summary by CodeRabbit
New Features
Bug Fixes