Skip to content

Commit

Permalink
Merge pull request #243 from troggy/fix-passport-local-username-field
Browse files Browse the repository at this point in the history
Make local auth to respect usernameField setting
  • Loading branch information
ghaiklor committed Apr 20, 2016
2 parents eb7e3fa + fb87052 commit cf35246
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions generators/authentication/templates/config/passport.js
Expand Up @@ -68,14 +68,14 @@ const SOCIAL_STRATEGY_CONFIG = {
/**
* Triggers when user authenticates via local strategy
* @param {Object} req Request object
* @param {String} email Email from body field in request
* @param {String} username Username from body field in request
* @param {String} password Password from body field in request
* @param {Function} next Callback
* @private
*/
const _onLocalStrategyAuth = (req, email, password, next) => {
const _onLocalStrategyAuth = (req, username, password, next) => {
User
.findOne({email: email})
.findOne({[LOCAL_STRATEGY_CONFIG.usernameField]: username})
.then(user => {
if (!user) return next(null, null, sails.config.errors.USER_NOT_FOUND);
if (!HashService.bcrypt.compareSync(password, user.password)) return next(null, null, sails.config.errors.USER_NOT_FOUND);
Expand Down

0 comments on commit cf35246

Please sign in to comment.