How to use the @auth0/angular-jwt.JwtHelperService function in @auth0/angular-jwt

To help you get started, we’ve selected a few @auth0/angular-jwt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / shared / services / login.service.ts View on Github external
constructor(
    private http: HttpClient,
    private configService: ConfigService,
    private jwtHelperService: JwtHelperService
  ) {
    super();
    this.loggedIn = !!localStorage.getItem('auth_token');
    // ?? not sure if this the best way to broadcast the status but seems to resolve issue on page refresh where auth status is lost in
    // header component resulting in authed user nav links disappearing despite the fact user is still logged in
    this._authNavStatusSource.next(this.loggedIn);
    this.baseUrl = configService.getApiURI();
    this.jwtHelperService = new JwtHelperService({
      tokenGetter: () => localStorage.getItem('')
    });
  }
github Okty-io / okty / src / app / core / services / api.service.ts View on Github external
constructor(private http: HttpClient) {
        this.baseUrl = environment.api.host;
        this.jwtHelper = new JwtHelperService();
    }
github Okty-io / okty / src / app / core / authentication / authentication.service.ts View on Github external
constructor(private api: ApiService) {
        this.user = null;
        this.subject = new BehaviorSubject(this.user);
        this.jwtHelper = new JwtHelperService();
    }
github gscdit / betterpledge-frontend / src / app / Service / authentication.service.ts View on Github external
currentUser(){
    let token=sessionStorage.getItem('token')
    let jwthelper=new JwtHelperService();
    return jwthelper.decodeToken(token)
  }
github KubeOperator / KubeOperator / fit2openshift / ui / src / app / shared / interceptor.service.ts View on Github external
intercept(request: HttpRequest, next: HttpHandler): Observable> {
    let token = null;
    const sessionUser = JSON.parse(localStorage.getItem('current_user'));
    if (sessionUser) {
      token = sessionUser.token;
      const helper = new JwtHelperService();
      const expirationDate = helper.getTokenExpirationDate(token);
      const now = new Date();
      if (expirationDate.getTime() - now.getTime() <= 1000 * 10 * 60) {
        this.session.refreshToken(token).subscribe((data) => {
          this.session.cacheToken(data);
        });
      }
    }
    if (token) {
      request = request.clone({
        setHeaders: {
          Authorization: `JWT ${token}`
        }
      });
    }
    return next.handle(request).pipe(
github gscdit / betterpledge-frontend / src / app / Service / authentication.service.ts View on Github external
currentUser(){
    let token=sessionStorage.getItem('token')
    let jwthelper=new JwtHelperService();
    return jwthelper.decodeToken(token)
  }
github clouditor / clouditor / clouditor-ui / src / app / auth.service.ts View on Github external
*  $$ /      $$ |$$ /  $$ |$$ |  $$ |$$ /  $$ |$$ |  $$ |    $$ /  $$ |$$ |  \__|
 *  $$ |      $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$\ $$ |  $$ |$$ |
 *  \$$$$$$\  $$ |\$$$$$   |\$$$$$   |\$$$$$$  |$$ |  \$$$   |\$$$$$   |$$ |
 *   \_______|\__| \______/  \______/  \_______|\__|   \____/  \______/ \__|
 *
 * This file is part of Clouditor Community Edition.
 */

import { Injectable } from '@angular/core';
import { JwtHelperService } from '@auth0/angular-jwt';
import { Router, ActivatedRoute } from '@angular/router';
import { HttpParams } from '@angular/common/http';

export const TOKEN_NAME = 'token';

const helper = new JwtHelperService();

@Injectable()
export class AuthService {

  constructor(private router: Router, private route: ActivatedRoute) {
    const params = new HttpParams({ fromString: window.location.hash.replace('#?', '') });

    const token = params.get('token');

    if (token) {
      this.login(token);
      this.router.navigate(['/']);
    }
  }

  isLoggedIn() {
github crossminer / scava / administration / scava-administration / src / app / shared / services / authentication / role-authorities.ts View on Github external
constructor(
    private localStorageService: LocalStorageService,
  ) {
    this.jwtHelper = new JwtHelperService();
  }

@auth0/angular-jwt

JSON Web Token helper library for Angular

MIT
Latest version published 1 year ago

Package Health Score

78 / 100
Full package analysis