Skip to content

Commit

Permalink
ea.password.loginName and ea.password.passwordName become ea.password…
Browse files Browse the repository at this point in the history
….loginFormFieldName and ea.password.passwordFormFieldName. Updated README to reflect changes.
  • Loading branch information
bnoguchi committed May 2, 2011
1 parent c9f8a85 commit 8a98435
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,30 @@ connect(
).listen(3000);
```

You can also configure more parameters (most are set to defaults) via
the same chainable API:

```javascript
everyauth.password
.loginFormFieldName('login') // Defaults to 'login'
.passwordFormFieldName('password') // Defaults to 'password'
```

If you want to see what the current value of a
configured parameter is, you can do so via:

```javascript
everyauth.password.loginFormFieldName(); // 'login'
everyauth.password.passwordFormFieldName(); // 'password'
```

To see all parameters that are configurable, the following will return an
object whose parameter name keys map to description values:

```javascript
everyauth.password.configurable();
```

## Setting up GitHub OAuth

```javascript
Expand Down Expand Up @@ -694,15 +718,18 @@ And that the function should return a `user` that is a user object or
a Promise that promises a user object.
```javascript
// For synchronous lookup situations, you can return a user
function (session, accessToken, extra, oauthUser) {
...
return { id: 'some user id', username: 'some user name' };
}

// OR

// For asynchronous lookup situations, you must return a Promise that
// will be fulfilled with a user later on
function (session, accessToken, extra, oauthUser) {
var promise = new everyauth.Promise();
var promise = this.Promise();
asyncFindUser( function (err, user) {
if (err) return promise.fail(err);
promise.fulfill(user);
Expand Down
14 changes: 7 additions & 7 deletions lib/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ var everyModule = require('./everymodule');
var password = module.exports =
everyModule.submodule('password')
.configurable({
loginName: 'the name of the login field. Same as what you put in your login form '
+ '- e.g., if <input type="text" name="username" />, then loginName '
loginFormFieldName: 'the name of the login field. Same as what you put in your login form '
+ '- e.g., if <input type="text" name="username" />, then loginFormFieldName '
+ 'should be set to "username".'
, passwordName: 'the name of the login field. Same as what you put in your login form '
+ '- e.g., if <input type="password" name="pswd" />, then passwordName '
, passwordFormFieldName: 'the name of the login field. Same as what you put in your login form '
+ '- e.g., if <input type="password" name="pswd" />, then passwordFormFieldName '
+ 'should be set to "pswd".'
, loginView: 'Either the name of the view (e.g., "login.jade") or the HTML string ' +
'that corresponds to the login page.'
, registerView: 'Either the name of the view (e.g., "register.jade") or the HTML string ' +
'that corresponds to the register page.'
, redirectPath: 'The path we redirect to after a login attempt.'
})
.loginName('login')
.passwordName('password')
.loginFormFieldName('login')
.passwordFormFieldName('password')
.get('getLoginPath', "the login page's uri path.")
.step('displayLogin')
.accepts('req res')
Expand Down Expand Up @@ -47,7 +47,7 @@ everyModule.submodule('password')
}
})
.extractLoginPassword( function (req, res) {
return [req.body[this.loginName()], req.body[this.passwordName()]];
return [req.body[this.loginFormFieldName()], req.body[this.passwordFormFieldName()]];
})
.getSession( function (req) {
return req.session;
Expand Down

0 comments on commit 8a98435

Please sign in to comment.