当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ng2-ui-auth.AuthService类代码示例

本文整理汇总了TypeScript中ng2-ui-auth.AuthService的典型用法代码示例。如果您正苦于以下问题:TypeScript AuthService类的具体用法?TypeScript AuthService怎么用?TypeScript AuthService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AuthService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: intercept

  intercept(
    request: HttpRequest<any>,
    next: HttpHandler
  ): Observable<HttpEvent<any>> {
    if (!this.auth) {
      this.auth = this.injector.get(AuthService);
    }

    if (this.auth.isAuthenticated()) {
      request = request.clone({
        setHeaders: {
          'X-Auth-Token': this.auth.getToken()
        }
      });
    }

    // Add CSRF token for the Play CSRF filter
    const token = this.cookieService.get('PLAY_CSRF_TOKEN');
    if (token) {
      // Play looks for a token with the name Csrf-Token
      // https://www.playframework.com/documentation/2.4.x/ScalaCsrf
      request = request.clone({
        setHeaders: {
          'Csrf-Token': token
        }
      });
    }

    return next.handle(request);
  }
开发者ID:epot,项目名称:Gifter,代码行数:30,代码来源:token-interceptor.ts

示例2: logout

    logout(): void {
        // clear token remove user from local storage to log user out

        this.auth.logout()
            .subscribe({
                complete: () => {
                    this.localstorage.clear('client_id');
                    this.user = null;
                    //                    UIService.notify('You have been logged out', 'info');
                    //                    $state.go('login');
                }
            });
        this.auth.removeToken();
        this.router.navigateByUrl('/login');
    }
开发者ID:megamtech,项目名称:angular-php-framework,代码行数:15,代码来源:authentication.service.ts

示例3:

 .map((response: Response) => {
     let token = response.json() && response.json().token;
     console.log(token);
     if (typeof token !== 'undefined') {
         this.auth.setToken(token);
         if (this.auth.isAuthenticated() === true) {
             this.getUserDetails();
             if (this.user['default_client_id'] !== null) {
                 this.setDefaultClientId(this.user['default_client_id']);
             }
             return true;
         }
     }
     return false;
 });
开发者ID:megamtech,项目名称:angular-php-framework,代码行数:15,代码来源:authentication.service.ts

示例4: isClientRole

 isClientRole() {
     if (this.auth.getPayload().data.role_id == 10) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:megamtech,项目名称:angular-php-framework,代码行数:7,代码来源:authentication.service.ts

示例5: loginWithGoogle

 loginWithGoogle() {
     this.auth.authenticate('google')
         .subscribe({
             error: (err: any) => this.eh.handleError(err),
             complete: () => this.router.navigateByUrl('main')
         });
 }
开发者ID:royipressburger,项目名称:ng2-ui-auth-example,代码行数:7,代码来源:login.component.ts

示例6: login

 login(loginData: ILoginData) {
     this.auth.login(loginData)
         .subscribe({
             error: (err: any) => this.eh.handleError(err),
             complete: () => this.router.navigateByUrl('main')
         });
 }
开发者ID:royipressburger,项目名称:ng2-ui-auth-example,代码行数:7,代码来源:login.component.ts

示例7: logout

 logout() {
     this.auth.logout()
         .subscribe({
             error: (err: any) => this.eh.handleError(err),
             complete: () => this.router.navigateByUrl('login')
         });
 }
开发者ID:royipressburger,项目名称:ng2-ui-auth-example,代码行数:7,代码来源:main.component.ts

示例8: getUserDetails

 getUserDetails() {
     var userDetails = this.auth.getPayload();
     if (typeof userDetails !== 'undefined') {
         this.user = userDetails.data;
     } else {
         return false;
     }
 }
开发者ID:megamtech,项目名称:angular-php-framework,代码行数:8,代码来源:authentication.service.ts

示例9: canActivate

 canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
   if (this.auth.isAuthenticated()) {
     return true;
   }
   console.log('unauthenticated navigating to login');
   this.router.navigateByUrl('/login');
   return false;
 }
开发者ID:epot,项目名称:Gifter,代码行数:8,代码来源:auth-guard.service.ts

示例10: link

 link() {
     this.auth.link('google')
         .subscribe({
             error: (err: any) => this.eh.handleError(err),
             complete: () => {
                 this.expiration = this.auth.getExpirationDate();
                 this.user = this.auth.getPayload();
             }
         });
 }
开发者ID:royipressburger,项目名称:ng2-ui-auth-example,代码行数:10,代码来源:main.component.ts


注:本文中的ng2-ui-auth.AuthService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。