-
Notifications
You must be signed in to change notification settings - Fork 555
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
Add validation to new root profile attributes #1657
Conversation
a48ccbd
to
d5319a6
Compare
src/field/username.js
Outdated
@@ -3,8 +3,8 @@ import { validateEmail } from './email'; | |||
import { databaseConnection } from '../connection/database'; | |||
import trim from 'trim'; | |||
|
|||
const DEFAULT_CONNECTION_VALIDATION = { username: { min: 1, max: 15 } }; | |||
const regExp = /^[a-zA-Z0-9_+\-.]+$/; | |||
const DEFAULT_CONNECTION_VALIDATION = { username: { min: 1, max: 128 } }; |
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.
The default didn't change, still 15 chars.
@@ -55,5 +55,5 @@ export function setUsername(m, str, usernameStyle = 'username', validateUsername | |||
} | |||
|
|||
export function usernameLooksLikeEmail(str) { | |||
return str.indexOf('@') > -1; | |||
return str.indexOf('@') > -1 && str.indexOf('.') > -1; |
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 you please use a more robust email validation library?
Ideally, the same library used in the backend should be used in Lock:
https://github.com/validatorjs/validator.js#client-side-usage
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.
this validation is only for cases that the browser doesn't support html5 validation, since we use that by default. we're not adding +20kb just to do email validation 😬
invalidChars.forEach(i => expectToFailWith(`aa${i}`)); | ||
}); | ||
it('accepts letters, numbers, `_`, `-`, `+` and `.`', () => { | ||
const validChars = `_-+.`.split(''); | ||
const validChars = `_+-.!#$'^\`~@`.split(''); |
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.
Suggestion: Update test title with new chars
Changes
Add default validation for new root profile attributes
Testing