carlospliego / sails-token-auth-setup

Token based authentication installation guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#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

About

Token based authentication installation guide


Languages

Language:JavaScript 100.0%