0.0.5 • Published 4 years ago

@shoppredigital/omnilogin v0.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

OmniLogin Node.js SDK

Getting Started

You need to install OmniLogin and set API credentials before you get started

If you not installed yet, you can install using below options

  1. DigitalOcean One Click Installation
  2. Installing by your own

Installation

npm i @shoppredigital/omnilogin -S

Usage

/**
 * Main application file
 */
if (!process.env.OMNILOGIN_SECRET) {
  process.env.OMNILOGIN_SECRET = 'your-secret';
}

if (!process.env.OMNILOGIN_URL) {
  process.env.OMNILOGIN_URL = 'https://login.yourdomain.com';
}

const http = require('http');
const express = require('express');

const bodyParser = require('body-parser');
const omnilogin = require('@shoppredigital/omnilogin');

const app = express();
const server = http.createServer(app);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

app.get('/secured', omnilogin.authenticate, (req, res) => {
  return res.json(req.user);
  // - req.user show user details, only if user session is active and url is secured by OmniLogin
});

server.listen(8000, '0.0.0.0', (err) => {
  if (err) return console.log('Error while starting nodejs', err);
  return console.log('Server started');
});