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


TypeScript AngularTokenService.userSignedIn方法代码示例

本文整理汇总了TypeScript中angular-token.AngularTokenService.userSignedIn方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AngularTokenService.userSignedIn方法的具体用法?TypeScript AngularTokenService.userSignedIn怎么用?TypeScript AngularTokenService.userSignedIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular-token.AngularTokenService的用法示例。


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

示例1: canActivate

  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
    console.log('User logged in?', this.authTokenService.userSignedIn());
    console.log('User type', this.authTokenService.currentUserType);

    if (this.authTokenService.userSignedIn()) {
      return this.authTokenService.validateToken().pipe(map(
          result => {
            console.log('Token validation result', result);
            if (this.authTokenService.currentUserData) {
              console.log('User data', this.authTokenService.currentUserData);
              if (this.authTokenService.currentUserType === "PLAYER") {
                return true
              }
              else {
                console.log('User not logged in, navigating to ', '/frontpage/overview');
                this.router.navigate(['/frontpage/overview']);
                return false
              }
            }
            else {
              console.log('User not logged in, navigating to ', '/frontpage/overview');
              this.router.navigate(['/frontpage/overview']);
              return false
            }
          }
      ));
    }

    console.log('User not logged in, navigating to ', '/frontpage/overview');
    this.router.navigate(['/frontpage/overview']);
    return false
  }
开发者ID:ffeldhaus,项目名称:soil,代码行数:32,代码来源:game-auth.guard.ts

示例2: canActivate

  canActivate() {
    console.log('User logged in?', this.authTokenService.userSignedIn());
    console.log('User type', this.authTokenService.currentUserType);

    if (this.authTokenService.userSignedIn()) {
      return this.authTokenService.validateToken().pipe(map(
          result => {
            console.log('Token validation result', result);
            if (this.authTokenService.currentUserData) {
              console.log('User data', this.authTokenService.currentUserData);
              if (this.authTokenService.currentUserType === "PLAYER") {
                this.router.navigate(['/game', this.authTokenService.currentUserData['game_id'],'/player',this.authTokenService.currentUserData['id']]);
                return true
              } else if (this.authTokenService.currentUserType === "ADMIN") {
                this.router.navigate(['/admin', this.authTokenService.currentUserData['id']]);
                return true
              } else if (this.authTokenService.currentUserType === "SUPERUSER") {
                this.router.navigate(['/superuser', this.authTokenService.currentUserData['id']]);
                return true
              }
              else {
                console.log('User not logged in, navigating to ', '/frontpage/overview');
                this.router.navigate(['/frontpage/overview']);
                return false
              }
            }
            else {
              console.log('User not logged in, navigating to ', '/frontpage/overview');
              this.router.navigate(['/frontpage/overview']);
              return false
            }
          },
      ));
    }
    else {
      console.log('User not logged in, navigating to ', '/frontpage/overview');
      this.router.navigate(['/frontpage/overview']);
      return false
    }
  }
开发者ID:ffeldhaus,项目名称:soil,代码行数:40,代码来源:app-auth.guard.ts


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