- Timestamp:
- 10/27/21 21:29:11 (3 years ago)
- Branches:
- dev
- Children:
- 32cd040
- Parents:
- d2b1fa6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Clients/Angular/finki-chattery/src/app/core/services/auth.service.ts
rd2b1fa6 rc205cc4 1 1 import { Injectable } from '@angular/core'; 2 import { User, UserManager } from 'oidc-client';2 import { User, UserManager, WebStorageStateStore } from 'oidc-client'; 3 3 import { Observable, of } from 'rxjs'; 4 4 5 5 import { environment } from '@env/environment'; 6 import { ApplicationUser, SelfUserResponse } from 'src/app/shared-app/models';6 import { ApplicationUser, ApplicationUserType, SelfUserResponse } from 'src/app/shared-app/models'; 7 7 import { BaseApiService } from 'src/app/shared-app/services/base-api.service'; 8 8 … … 17 17 response_type: 'id_token token', 18 18 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 }) 20 23 }); 21 24 … … 23 26 public oidcUser: User | null = null; 24 27 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 } 26 40 27 41 public login(): void { … … 38 52 } 39 53 return false; 54 } 55 56 public isStudent(): boolean { 57 return this.user?.userType === ApplicationUserType.Student; 40 58 } 41 59
Note:
See TracChangeset
for help on using the changeset viewer.