1.0.5 • Published 8 years ago

passport-depositphotos v1.0.5

Weekly downloads
3
License
-
Repository
gitlab
Last release
8 years ago

passport-depositphotos

build status coverage report

An abstract class implementing Passport's strategy API.

Install

$ npm install passport-depositphotos

Usage

This module use an abstract Strategy class that is intended to be subclassed when implementing concrete authentication strategies. Once implemented, such strategies can be used by applications that utilize Passport middleware for authentication.

Configure Strategy

The Depositphotos authentication strategy authenticates users using a Depositphotos account. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a API key.

passport.use(new DepositphotosStrategy({
    apiKey: process.env.DEPOSITPHOTOS_API_KEY,
  }, function(accessToken, profile, done) {
    User.findOrCreate({ depositphotosId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

Tests

$ npm install
$ npm test

Credits

License

The MIT License

Copyright (c) 1988-2017 Oleksii Volkov [https://ovolkov.pro/](https://ovolkov.pro/)

1.0.5

8 years ago

1.0.3

8 years ago

1.0.0

8 years ago