Coder Social home page Coder Social logo

angular-http-auth's Introduction

HTTP Auth Interceptor Module

for AngularJS

This is the implementation of the concept described in Authentication in AngularJS (or similar) based application.

Launch demo here or switch to gh-pages branch for source code of the demo.

Manual

This module installs $http interceptor and provides the 'authService'.

The $http interceptor does the following: the configuration object (this is the requested URL, payload and parameters) of every HTTP 401 response is buffered and everytime it happens, the 'event:auth-loginRequired' message is broadcasted from $rootScope.

The 'authService' has only one method: #loginConfirmed(). You are responsible to invoke this method after user logged in. You may optionally pass in a data argument to the loginConfirmed method which will be passed on to the loginConfirmed $broadcast. This may be useful, for example if you need to pass through details of the user that was logged in. The 'authService' will then retry all the requests previously failed due to HTTP 401 response.

###Typical use case:

  • somewhere the: $http(...).then(function(response) { do-something-with-response }) is invoked,
  • the response of that requests is a HTTP 401,
  • 'http-auth-interceptor' captures the initial request and broadcasts 'event:auth-loginRequired',
  • your application intercepts this to e.g. show a login dialog (or whatever else),
  • once your application figures out the authentication is OK, you are to call: authService.loginConfirmed(),
  • your initial failed request will now be retried and finally, the do-something-with-response will fire.

angular-http-auth's People

Contributors

clkao avatar julianjelfs avatar mbrio avatar witoldsz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.