1.0.2 • Published 4 years ago

@awanisius/just-login v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 years ago

Allows login to Facebook, Github, Google, Instagram, Linkedin, Pinterest, Steam and Twitter.

Requirements and Use

You can install this package via any package registry or build it yourself from the source.

npm package (recommended)

This package is currently available in registry.npmjs.org and npm.pkg.github.com. It can be installed using your preferred package manager (e.g. npm, Yarn, pnpm). See the documentation for each package manager for installation command. and I strongly recommend installing with an option such as --exact to install the packages as exact versions.

  • npm: npm install @awanisius/just-login --save
  • Yarn: yarn add @awanisius/just-login --dev

Use

import express from 'express';
import justLogin from 'just-login';
import log from 'log-decorator';

import UserModel from './models/UserModel';

const app = express();

justLogin({
	UserModel: UserModel,
	app: app,
	providersConfig: {
		facebook: {
			facebookId: process.env.FACEBOOK_ID,
			facebookSecret: process.env.FACEBOOK_SECRET,
			scope: ['read_stream', 'publish_actions']
		},
		google: true
	}
});

The package just-login automatically generates two routes to have social login in your application:

/auth/facebook

/auth/facebook/callback

For this you need pass to just login an instance of your express application and a user model like that:

import mongoose from 'mongoose';

/**
 * User Schema
 */
const userSchema = new mongoose.Schema({
	name: { type: String, index: true },
	email: { type: String, unique: true, index: true },
	password: { type: String },
	facebook: { type: String },
	twitter: { type: String },
	google: { type: String },
	github: { type: String },
	instagram: { type: String },
	linkedin: { type: String },
	steam: { type: String },
	profile: {
	  name: { type: String },
	  gender: { type: String },
	  location: { type: String },
	  website: { type: String },
	  picture: { type: String }
	}
});

/**
 * Registration
 */
const User = mongoose.model('User', userSchema);
module.exports = User;

I Love Coffee

ko-fi