Socket
Book a DemoInstallSign in
Socket

angular-token-app

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-token-app

![Angular-Token](https://raw.githubusercontent.com/neroniaky/angular-token/master/docs/angular-token-logo.png)

16.0.0
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Angular-Token

npm version npm downloads Build Status Angular Style Guide

🔑 Token based authentication service for Angular with interceptor and multi-user support. Works best with the devise token auth gem for Rails.

👋 This library has been renamed to Angular-Token! Please follow the migration guide.

  • 🚀 View to demo on Stackblitz
  • ✨ Learn about it on the docs site
  • 🔧 Support us by contributing

Install

  • Set up a Rails with Devise Token Auth

  • Install Angular-Token via NPM with

    npm install angular-token
    
  • 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: [ ... ],
        bootstrap:    [ ... ]
    })
    
  • (Maybe Optional) Fix injection context runtime error After installing this package, if you get an Error: inject() must be called from an injection context when running your app, add the following to your typescript path config in the tsconfig[.app].json file:

    "paths": {
      "@angular/*": [ "./node_modules/@angular/*" ]
    }
    

Use

  • 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)
    );
    
  • 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)
    );
    
  • 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)
    );
    

Contributors


Jan-Philipp Riethmacher

Arjen Brandenburgh

License

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

FAQs

Package last updated on 09 Nov 2023

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.