Skip to content
Browse files

Added documentation for custom validateRegistration for the password …

…module.
  • Loading branch information...
1 parent 7f647c4 commit 4c938d61c5a8d35183693d6e27e5699724756c8c @bnoguchi committed Jun 10, 2011
Showing with 30 additions and 1 deletion.
  1. +29 −0 README.md
  2. +1 −1 lib/modules/password.js
View
29 README.md
@@ -472,6 +472,35 @@ You can configure this parameter in one of *3* ways. Why 3? Because there are 3
});
```
+### Password Recipe 4: Customize Your Registration Validation
+
+By default, `everyauth.password` automatically
+
+- validates that the login (or email or phone, depending on what you authenticate with -- see Password Recipe 2) is present in the login http request,
+- validates that the password is present
+- validates that an email login is a correctly formatted email
+- validates that a phone login is a valid phone number
+
+If any of these validations fail, then the appropriate errors are generated and accessible to you in your view via the `errors` view local variable.
+
+If you want to add additional validations beyond this, you can do so by configuring the step, `validateRegistration`:
+
+```javascript
+everyauth.password
+ .validateRegistration( function (newUserAttributes, baseErrors) {
+ // Here, newUserAttributes is the hash of parameters extracted from the incoming request.
+ // baseErrors is the array of errors generated by the default automatic validation outlined above
+ // in this same recipe.
+
+ // First, validate your errors. Here, validateUser is a made up function
+ var moreErrors = validateUser( newUserAttributes );
+ if (moreErrors.length) baseErrors.push.apply(baseErrors, moreErrors);
+
+ // Return the array of errors, so your view has access to them.
+ return baseErrors;
+ });
+```
+
## Setting up GitHub OAuth
```javascript
View
2 lib/modules/password.js
@@ -234,7 +234,7 @@ everyModule.submodule('password')
.accepts('login password extraParams')
.promises('newUserAttributes')
.step('validateRegistrationBase')
- .description('Basic validation done by `everyauth`')
+ .description("Basic validation done by `everyauth`. Don't edit this. Configure validateRegistration instead.")
.accepts('newUserAttributes')
.promises('baseErrors')
.step('validateRegistration')

0 comments on commit 4c938d6

Please sign in to comment.
Something went wrong with that request. Please try again.