Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 765 Bytes

README.md

File metadata and controls

49 lines (32 loc) · 765 Bytes

#SailsJs Token Based Authentication Setup

Globals

$ npm install -g sails

Create a sails app

$ sails new myApp
$ cd myApp

Files

1 ) Copy every file to its corresponding folder

2 ) Add this to config/policies.js

'*': "hasToken",
UserController: {
    "create": true
},
AuthController: {
    '*': true
}

3 ) Change the value of config/tokenSecret.js

Install Dependencies

$ npm install --save passport
$ npm install --save passport-local
$ npm install --save bcrypt-nodejs
$ npm install --save jsonwebtoken
$ npm install --save express-jwt

Endpoints

Create user

POST user/

Login

POST auth/login

Logout

DELETE auth/logout

Validate Token

POST auth/validate_token