Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-hb-auth

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-hb-auth

Angular Auth Interceptor

  • 1.0.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

HB Auth Interceptor

This is a simple Angular Auth Token interceptor.

How to Install

$ npm install --save-dev angular-hb-auth
$ bower install angular-hb-auth

How to Use

This module is an simple way to make login token based.

Below is an example of how to use it with angular:

Load module in your app.js, and set the configurations:

  angular
    .module('yourApp', ['hbAuth'])
    .run(['$state', '$rootScope', '$http', 'hbAuth.auth', function ( $state, $rootScope, $http, AuthService) {

      AuthService.setConfig({
        loginRedirect: '/login',
        loggedInRedirect: '/dashboard',
        headerToken: 'Authorization'
      });

      $rootScope.$on("$stateChangeStart", function(event, next, nextParams, fromState) {
        if (!AuthService.isLoggedIn()) {
          if (next.name !== "login") {
            event.preventDefault();
            $state.go('login');
          }
        }
      });
    }]);

NOTE If you don't want to set config, default values are:

  angular
    .module('hbAuth', [])
    .value('hbAuth.config', {
      loginRedirect: '/signin',
      loggedInRedirect: '/menu',
      headerToken: 'Authorization'
    });

Push the authInterceptor to interceptors in your routes.js:

  angular
  .module('yourApp')
    .config(['$httpProvider', function ($httpProvider) {

      $httpProvider.interceptors.push('hbAuth.authInterceptor');
    }]);

Keywords

FAQs

Package last updated on 12 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc