@@ -2,32 +2,46 @@ import { Component, OnInit } from '@angular/core';
22import { environment } from 'src/environments/environment' ;
33import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service' ;
44import { LoginService } from '../../../login/services/login.service' ;
5+ import { SocialUser } from 'angularx-social-login' ;
6+ import { SocialAuthService } from 'angularx-social-login' ;
57
68@Component ( {
79 selector : 'app-user' ,
810 templateUrl : './user.component.html' ,
911 styleUrls : [ './user.component.scss' ] ,
1012} )
1113export class UserComponent implements OnInit {
14+ user : SocialUser ;
15+ userPhoto : string ;
1216 userName : string ;
1317 userEmail : string ;
1418 isProduction = environment . production ;
1519
16- constructor ( private azureAdB2CService : AzureAdB2CService , private loginService : LoginService ) { }
20+ constructor (
21+ private azureAdB2CService : AzureAdB2CService ,
22+ private loginService : LoginService ,
23+ private authService : SocialAuthService ,
24+ ) { }
1725
1826 ngOnInit ( ) : void {
19- if ( this . isProduction ) {
27+ if ( this . isProduction ) {
2028 if ( this . azureAdB2CService . isLogin ( ) ) {
2129 this . userName = this . azureAdB2CService . getName ( ) ;
2230 this . userEmail = this . azureAdB2CService . getUserEmail ( ) ;
2331 this . azureAdB2CService . setTenantId ( ) ;
2432 }
25- } else {
33+ } else {
2634 if ( this . loginService . isLogin ( ) ) {
2735 this . userName = this . loginService . getName ( ) ;
2836 this . userEmail = this . loginService . getUserEmail ( ) ;
2937 this . azureAdB2CService . setTenantId ( ) ;
3038 }
3139 }
40+ this . authService . authState . subscribe ( ( user ) => {
41+ this . user = user ;
42+ this . userPhoto = user . photoUrl ;
43+ localStorage . setItem ( 'googleUserPhoto' , this . userPhoto ) ;
44+ } ) ;
45+ this . userPhoto = localStorage . getItem ( 'googleUserPhoto' ) ;
3246 }
3347}
0 commit comments