npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sails-hook-userlogin

v1.1.0

Published

Sails js installable hook that implements User authentication

Downloads

10

Readme

sails-hook-userlogin

Basic User login functionality hook for sails.

It uses passports and a variety of Passport Strategies to allow login using several Social networks

Passport Strategies

  • Local
  • Google
  • Twitter
  • Facebook
  • Github

Routes

The Hook intalls and handle the following routes

  • POST /login
  • /google/*
  • /twitter/*
  • /facebook/*
  • /github/*
  • /loggeduser
  • /logout

Configuration

By default the Hook will provide local Strategy login. It would use a user model called User and the default login callback will send a json representation of the user upon success.

All these can be changed and Social Network login can be enabled by adding a userlogin.js file under your sails config directory.

For example to configure login for google and twitter social networks the config would look like this.

module.exports.userlogin = {  
  google: {  
    clientID: 'YOUR-GOOGLE-CLIENTID',  
    clientSecret: 'PdgdRaq8VJC6EZjS5-Epf9RF',  
    callbackURL: 'http://localhost:1337/google/return'  
  },  
  twitter: {  
    clientID: 'YOUR-TWITTER-CONSUMER-KEY',  
    clientSecret: 'YOUR-TWITTER-CONSUMER_SECRET',  
    callbackURL: "https//localhost:1337/twitter/return"  
  }  
};  

The user model name can be changed by using the 'userModel' setting.

module.exports.userlogin = {  
  userModel: 'Customer'  
};

The Hook will check is the model exists. If it doesnt, the Hook will inject it.

Local login functionality can be suppressed by setting local to false.

module.exports.userlogin = {  
  local: false  
};

When attempting login a parameter 'redirecturl' can be passed to redirect to the desired location upon a successful login. By default it would redirect to the root if no redirect url is provided. If the login is unsuccessful a HTTP 403 (Forbidden) is returned, HTTP 200 otherwise.

http://localhost:1337/google/login?redirecturl=http//www.google.com