Created
March 5, 2020 04:09
-
-
Save jsdmultisys/e09b47185824d45e2b21970c468f8ce4 to your computer and use it in GitHub Desktop.
password creation
This file contains 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
``` | |
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