Skip to content

dvpnt/passport-cultreg-strategy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passport-cultreg-strategy

Build Status Coverage Status NPM Version

Passport strategy for authenticating with Cultreg using the OAuth 2.0 API.

Install

$ npm i passport-cultreg-strategy

Usage

Configure Strategy

var passport = require('passport'),
    CultregStrategy = require('passport-cultreg-strategy').Strategy;

passport.use(new CultregStrategy({
    clientID: '<app id>',
    clientSecret: '<secret key>',
    callbackURL: 'http://localhost:3000/auth/cultreg/callback'
  },
  function(accessToken, refreshToken, profile, cb) {
    User.findOrCreate({cultregId: profile.id}, function (err, user) {
      return cb(err, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'cultreg' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/cultreg',
  passport.authenticate('cultreg'));

app.get('/auth/cultreg/callback',
  passport.authenticate('cultreg', {failureRedirect: '/login'}),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

License

The MIT License

About

passport strategy for authenticating with cultreg.ru

Resources

License

Stars

Watchers

Forks

Packages

No packages published