Ignore:
Timestamp:
10/27/21 21:29:11 (3 years ago)
Author:
Стојков Марко <mst@…>
Branches:
dev
Children:
32cd040
Parents:
d2b1fa6
Message:

Ask question finishing touches

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Clients/Angular/finki-chattery/src/app/core/services/auth.service.ts

    rd2b1fa6 rc205cc4  
    11import { Injectable } from '@angular/core';
    2 import { User, UserManager } from 'oidc-client';
     2import { User, UserManager, WebStorageStateStore } from 'oidc-client';
    33import { Observable, of } from 'rxjs';
    44
    55import { environment } from '@env/environment';
    6 import { ApplicationUser, SelfUserResponse } from 'src/app/shared-app/models';
     6import { ApplicationUser, ApplicationUserType, SelfUserResponse } from 'src/app/shared-app/models';
    77import { BaseApiService } from 'src/app/shared-app/services/base-api.service';
    88
     
    1717    response_type: 'id_token token',
    1818    scope: 'openid app.api.finki-chattery profile',
    19     post_logout_redirect_uri: window.location.origin
     19    post_logout_redirect_uri: window.location.origin,
     20    filterProtocolClaims: true,
     21    loadUserInfo: true,
     22    userStore: new WebStorageStateStore({ store: window.localStorage })
    2023  });
    2124
     
    2326  public oidcUser: User | null = null;
    2427
    25   constructor(private baseApi: BaseApiService) {}
     28  constructor(private baseApi: BaseApiService) {
     29    this.userManager.getUser().then((user) => {
     30      this.oidcUser = user;
     31      this.user = new ApplicationUser(
     32        user?.profile.id,
     33        user?.profile.userType,
     34        user?.profile.emailAddress,
     35        user?.profile.username,
     36        user?.profile.isVerified
     37      );
     38    });
     39  }
    2640
    2741  public login(): void {
     
    3852    }
    3953    return false;
     54  }
     55
     56  public isStudent(): boolean {
     57    return this.user?.userType === ApplicationUserType.Student;
    4058  }
    4159
Note: See TracChangeset for help on using the changeset viewer.