Skip to content

Instantly share code, notes, and snippets.

@jsdmultisys
Created March 5, 2020 04:09
Show Gist options
  • Save jsdmultisys/e09b47185824d45e2b21970c468f8ce4 to your computer and use it in GitHub Desktop.
Save jsdmultisys/e09b47185824d45e2b21970c468f8ce4 to your computer and use it in GitHub Desktop.
password creation
```
async register ({ request, response, transform, auth }) {
const validation = await validate(request.only(Retailer.validateFields), Retailer.rules, Retailer.messages)
if (validation.fails()) {
return response.status(422).json({errors: validation.messages()})
}
// Validate password
const passwordValidation = new PasswordPolicy({
containsAtLeast: {
atLeast: 3,
expressions: [ charsets.lowerCase, charsets.upperCase, charsets.numbers ]
}
})
if(passwordValidation.check(request.input('password')) === false) {
return response.status(401).json({error: 'Password does not met the minimum requirements.'})
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment