Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
/ passport-magic Public archive

Magic is a Passport.js strategy that enables passwordless authentication middleware for any Express.js based application.

License

Notifications You must be signed in to change notification settings

magiclabs/passport-magic

Repository files navigation

Magic Authentication For Passport JS

Tests

Integrate Magic passwordless authentication with your Passport.js application.

License · Changelog · Contributing Guide

📖 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);

About

Magic is a Passport.js strategy that enables passwordless authentication middleware for any Express.js based application.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published