1.0.2 โ€ข Published 2 years ago

@ebyrds/passport-magic v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Magic Authentication For Passport JS

EByrdS/passport-magic

This is a fork from https://github.com/magiclabs/passport-magic, as that repo doesn't seem to be maintained anymore.

Integrate Magic passwordless authentication with your Passport.js application.

๐Ÿ“– Documentation

See the developer documentation to learn how you can integrate Magic into your Passport.js application in a matter of minutes.

๐Ÿ”— Installation

Integrating your Passport.js application with Magic will require our server-side NPM package:

# Via NPM:
npm install --save passport-magic

# Via Yarn:
yarn add passport-magic

โšก๏ธ Quick Start

const passport = require('passport');
const MagicStrategy = require('passport-magic').Strategy;

const strategy = new MagicStrategy(async function(user, done) {
  const userMetadata = await magic.users.getMetadataByIssuer(user.issuer);
  const existingUser = await users.findOne({ issuer: user.issuer });
  if (!existingUser) {
    /* Create new user if doesn't exist */
    return signup(user, userMetadata, done);
  } else {
    /* Login user if otherwise */
    return login(user, done);
  }
});

passport.use(strategy);