Skip to content

πŸ”‘ Token based authentication service for Angular2 (ng2) with multi-user support. Works best with the devise token auth gem for Rails. Demo:

License

Notifications You must be signed in to change notification settings

CacherApp/angular-token

This branch is 9 commits ahead of, 44 commits behind neroniaky/angular-token:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a55cc26 Β· Aug 19, 2024
Apr 15, 2020
Jul 24, 2018
Jul 24, 2018
Aug 19, 2024
Oct 25, 2018
Jul 24, 2018
Apr 15, 2020
Jul 24, 2018
Apr 15, 2020
Jul 24, 2018
Jul 24, 2018
Jul 24, 2018
Jul 24, 2018
Apr 15, 2020
Oct 25, 2018
Jul 24, 2018
Jun 16, 2018

Repository files navigation

πŸ‘‹ 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:                'example@example.org',
        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:    'example@example.org',
        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)

About

πŸ”‘ Token based authentication service for Angular2 (ng2) with multi-user support. Works best with the devise token auth gem for Rails. Demo:

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 83.4%
  • HTML 12.0%
  • JavaScript 3.8%
  • SCSS 0.8%