sails-auth icon indicating copy to clipboard operation
sails-auth copied to clipboard

Can't use local authentication with 2.0.0-alpha2

Open wbprice opened this issue 10 years ago • 3 comments

Following this guide, I was unable to authenticate passing identifier and password to POST /auth/local. After downgrading sails-auth to 1.3.1, everything worked as expected.

wbprice avatar Aug 28 '15 16:08 wbprice

Hi Raul. I've spoken about this with both of the maintainers of sails-auth pretty extensively (one of whom wrote the article), so they're aware of the details. However:

Replication Steps

  • Follow setup steps 1 and 2 in this sails-permisssions guide.
  • POST /auth/local/, passing { identifier: admin, password: admin1234 } in the body. I used Postman to do this.
  • Response from POST is a 500 error. Sails console gives a gnarly stack trace starting with:
error: Sending 500 ("Server Error") response: 
 Error: Unknown authentication strategy "local"
    at attempt (/Users/blaine/Documents/reviews/node_modules/sails-permissions/node_modules/sails-auth/node_modules/passport/lib/middleware/authenticate.js:166:37)

Package.json

{
  "name": "reviews",
  "private": true,
  "version": "0.0.0",
  "description": "a Sails application",
  "keywords": [],
  "dependencies": {
    "ejs": "~0.8.4",
    "grunt": "0.4.2",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-contrib-coffee": "~0.10.1",
    "grunt-contrib-concat": "~0.3.0",
    "grunt-contrib-copy": "~0.5.0",
    "grunt-contrib-cssmin": "~0.9.0",
    "grunt-contrib-jst": "~0.6.0",
    "grunt-contrib-less": "0.11.1",
    "grunt-contrib-uglify": "~0.4.0",
    "grunt-contrib-watch": "~0.5.3",
    "grunt-sails-linker": "~0.9.5",
    "grunt-sync": "~0.0.4",
    "include-all": "~0.1.3",
    "lodash": "^3.10.1",
    "rc": "~0.5.0",
    "sails": "~0.11.0",
    "sails-auth": "^2.0.0",
    "sails-disk": "~0.10.0",
    "sails-permissions": "^1.4.4"
  },
  "scripts": {
    "debug": "node debug app.js",
    "start": "node app.js"
  },
  "main": "app.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/wbprice/reviews.git"
  },
  "author": "wbprice",
  "license": ""
}

As noted above, reverting to an earlier version of sails-auth fixes the issue. Above POST request behaves as expected.

wbprice avatar Sep 09 '15 01:09 wbprice

I confirm this issue with [email protected]

wasd171 avatar Sep 21 '15 11:09 wasd171

I meet this problem, resolved by following:

change your config/bootstrap.js to load your Passport providers on startup by adding the following line: sails.services.passport.loadStrategies();

YoleYu avatar Jan 09 '16 11:01 YoleYu