Git Product home page Git Product logo

angular-token's Introduction

๐Ÿ‘‹ This library has been renamed to Angular-Token! ๐Ÿ‘‹

Please follow the migration guide


Angular-Token

Angular-Token

npm version npm downloads Build Status Angular Style Guide

Token based authentication service for Angular with support for Http Interceptors and multiple user. Angular-Token works best with the devise token auth gem for Rails. Any contribution is much appreciated.

Install

  1. Set up a Rails with Devise Token Auth

  2. Install Angular-Token via NPM with

    npm install angular-token
  3. Import and add AngularTokenModule to your main module and call the 'forRoot' function with the config. Make sure you have HttpClientModule imported too.

    import { AngularTokenModule } from 'angular-token';
    
    @NgModule({
        imports: [
            ...,
            HttpClientModule,
            AngularTokenModule.forRoot({
              ...
            })
        ],
        declarations: [ ... ],
        providers:    [ AngularTokenModule ],
        bootstrap:    [ ... ]
    })

Use

  1. Register your user

    constructor(private tokenService: AngularTokenService) { }
    
    this.tokenService.registerAccount({
        login:                '[email protected]',
        password:             'secretPassword',
        passwordConfirmation: 'secretPassword'
    }).subscribe(
        res =>      console.log(res),
        error =>    console.log(error)
    );
  2. Sign in your user

    constructor(private tokenService: AngularTokenService) { }
    
    this.tokenService.signIn({
        login:    '[email protected]',
        password: 'secretPassword'
    }).subscribe(
        res =>      console.log(res),
        error =>    console.log(error)
    );
  3. Now you can use HttpClient to access private resources

    constructor(http: HttpClient) { }
    
    this.http.get('private_resource').subscribe(
        res =>      console.log(res),
        error =>    console.log(error)
    );

Documentation

In the Angular-Token Wiki you'll find lots of additional information and answers to the most frequently asked questions.

Contributors


Jan-Philipp Riethmacher

Arjen Brandenburgh

License

The MIT License (see the LICENSE file for the full text)

angular-token's People

Contributors

arjenbrandenburgh avatar avatsaev avatar bentedder avatar colmben avatar diegoh avatar dks17 avatar grafexy avatar greenkeeper[bot] avatar greenkeeperio-bot avatar jburich avatar lukaselmer avatar marcpeabody avatar neroniaky avatar rjiang-bb avatar rmorlok avatar roterski avatar tobmaster avatar tybot204 avatar xxxxlr 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.