1.0.0 • Published 7 years ago
tmj-passport v1.0.0
tmj-passport
Temporary TMJ authentication strategy for Passport .
Installation
Since we dont have the npm package we can use our private git repo for our installation.
npm install git+ssh:github.com/spartangian/tmj-passport.git
Usage
Configure Strategy
Currently the TMJ authentication strategy autenticates user by request to Betalk Login API.
var TMJStrategy = require('tmj-passport');
passport.use(new TMJStrategy({
apiToken: 'permitted token by tmj',
url: 'api url given by tmj',
usernameField: 'name of the username field| default to username',
passwordField: 'name of the password field| default to password'
}));
Authenticate Requests
Use passport.authenticate()
, specify the 'tmj'
strategy to authenticate
requests.
For example, as route middleware in an Express application:
app.post('/login', function(req, res) {
passport.authenticate('tmj', function(err, user, info) {
var throwErr = err || info;
if (throwErr) {
return res.status(400).send(throwErr);
}
req.logIn(user, function(err) {
if (err) {
return res.status(400).send(err);
}
return res.json(user);
});
})(req,res);
});
Credits
- Passport-Local
- Jared Hanson
TMJP Web Development Team.
License
Copyright (c) 2016 TMJ Philippines
1.0.0
7 years ago