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

coins-logon-widget

v2.3.0

Published

COINS Logon Widget. Injectable utility to manage browser authorization with COINS

Downloads

51

Readme

Codeship Status for MRN-Code/coins-logon-widget

COINS Logon Widget

Injectable utility to manage browser authorization with COINS.

Use

var widget = new CoinsLogonWidget({
    el: document.getElementById('logon-area'),
    baseUrl: 'http://localhost:9000/api/v1',
    authCookieName: 'COINS_Auth_User-production'
});

Authorization Check

Add a checkAuth property with a value of true to make the widget perform an initial authorization check against your API:

var widget = new CoinsLogonWidget({
    el: document.getElementById('logon-area'),
    baseUrl: 'http://localhost:9000/api/v1',
    authCookieName: 'COINS_Auth_User-production',
    checkAuth: true,
});

The widget will change to its logged-in state if the check is successful.

Redirect

To make the widget redirect upon successful log in, add a redirect property with a value of true and a redirectUrl property with the URL to redirect to.

var widget = new CoinsLogonWidget({
    el: document.getElementById('logon-area'),
    baseUrl: 'http://localhost:9000/api/v1',
    authCookieName: 'COINS_Auth_User-production',
    redirect: true,
    redirectUrl: 'http://localhost:9000/my-app/',
});

Methods

You may call these methods on an instance of the widget:

Destroy

Destroy the widget’s elements and remove all event handlers.

widget.destroy()

Events

The widget extends Olical’s EventEmitter: all of its methods are available on an instance of CoinsLogonWidget. The widget has a few custom events for which you can attach handlers:

Invalid

Fired when one or more of the widget’s form fields aren’t valid.

widget.on('invalid', function(validations) {});

Login Init

Fired when the widget begins a login API call.

widget.on('login:init', function() {});

Login Error

Fired when the widget receives an error from the login API call.

widget.on('login:error', function(error) {});

Login Account Expired

Fired when the widget receives an “account expired” response from the login API call.

widget.on('login:accountExpired', function(apiResponse) {});

Login Account Will Expire

Fired when the widget receives an “account will expire” response from the login API call.

widget.on('login:accountWillExpire', function(apiResponse) {});

Login Password Expired

Fired when the widget receives a “password expired” response from the login API call.

widget.on('login:passwordExpired', function(apiResponse) {});

Login Password Will Expire

Fired when the widget receives a “password will expire” response from the login API call.

widget.on('login:passwordWillExpire', function(apiResponse) {});

Login Success

Fired when the widget receives a successful response from the login API call.

widget.on('login:success', function(apiResponse) {});

Logout Init

Fired when the widget begins a logout API call.

widget.on('logout:init', function() {});

Logout Error

Fired when the widget receives an error response from the logout API call.

widget.on('logout:error', function(error) {});

Logout Success

Fired when the widget receives a successful response from the logout API call.

widget.on( 'logout:success', function(apiResponse) {});

See examples/index.html for more examples of widget use.

Project Setup

  1. Make sure you have Node.js or io.js installed on your machine.
  2. Install libsass (brew install libsass on a Mac with Homebrew).
  3. Make sure Grunt.js is installed globally: npm install -g grunt-cli
  4. Clone the repo: git clone [email protected]:MRN-Code/coins-logon-widget.git
  5. Install the project’s dependencies with NPM:
    1. cd into the repo’s directory
    2. Run npm install

Project Tasks

This project relies on Grunt to run tasks. (See its getting started guide for basic info.) Currently, three tasks exist:

  • grunt: Build the project’s un-minified styles and scripts
  • grunt build: Build the project’s minified styles and scripts, suitable for production.
  • grunt serve: Spin up a connect server and rebuild the styles and scripts when they change. Useful for development on the project.
  • grunt test: Initializes a mock api server, and fires off in-browser testing in multiple browsers in parallel.

Changelog

  • 2.0.0 single arg config, mandatory baseUrl and authCookieName