diff --git a/src/app/modules/login/services/login.service.spec.ts b/src/app/modules/login/services/login.service.spec.ts index 36257da50..3dd8ba0c2 100644 --- a/src/app/modules/login/services/login.service.spec.ts +++ b/src/app/modules/login/services/login.service.spec.ts @@ -1,6 +1,6 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; -import { SocialAuthService } from 'angularx-social-login'; +import {SocialAuthService, SocialUser} from 'angularx-social-login'; import { CookieService } from 'ngx-cookie-service'; import { of } from 'rxjs'; @@ -13,6 +13,9 @@ describe('LoginService', () => { let socialAuthService: SocialAuthService; let account; const socialAuthServiceStub = jasmine.createSpyObj('SocialAuthService', ['signOut', 'signIn']); + socialAuthServiceStub.signIn.and.returnValue(new Promise( resolve => { + return {photoUrl: ''}; + })); const cookieStoreStub = {}; beforeEach(() => { diff --git a/src/app/modules/login/services/login.service.ts b/src/app/modules/login/services/login.service.ts index 41ea9a7bf..a3ebc5d1a 100644 --- a/src/app/modules/login/services/login.service.ts +++ b/src/app/modules/login/services/login.service.ts @@ -20,7 +20,9 @@ export class LoginService { } signIn() { - this.socialAuthService.signIn(GoogleLoginProvider.PROVIDER_ID); + this.socialAuthService.signIn(GoogleLoginProvider.PROVIDER_ID).then(user => { + localStorage.setItem('googleUserPhoto', user.photoUrl); + }); } logout() { this.socialAuthService.signOut(); diff --git a/src/app/modules/shared/components/user/user.component.html b/src/app/modules/shared/components/user/user.component.html index c78437923..836536fb9 100644 --- a/src/app/modules/shared/components/user/user.component.html +++ b/src/app/modules/shared/components/user/user.component.html @@ -1,7 +1,7 @@
- user-icon + user-icon -

{{userName}}

-

{{userEmail}}

+

{{ userName }}

+

{{ userEmail }}

-
\ No newline at end of file + diff --git a/src/app/modules/shared/components/user/user.component.scss b/src/app/modules/shared/components/user/user.component.scss index 41e238600..cb98394c1 100644 --- a/src/app/modules/shared/components/user/user.component.scss +++ b/src/app/modules/shared/components/user/user.component.scss @@ -1,5 +1,11 @@ @import '../../../../../styles/colors.scss'; +.round { + width:40px; + height:40px; + border-radius:150px; +} + .user-profile { color: black; cursor: pointer; diff --git a/src/app/modules/shared/components/user/user.component.ts b/src/app/modules/shared/components/user/user.component.ts index 917d60a98..8b4e723fa 100644 --- a/src/app/modules/shared/components/user/user.component.ts +++ b/src/app/modules/shared/components/user/user.component.ts @@ -9,25 +9,30 @@ import { LoginService } from '../../../login/services/login.service'; styleUrls: ['./user.component.scss'], }) export class UserComponent implements OnInit { + userPhoto: string; userName: string; userEmail: string; isProduction = environment.production; - constructor(private azureAdB2CService: AzureAdB2CService, private loginService: LoginService) {} + constructor( + private azureAdB2CService: AzureAdB2CService, + private loginService: LoginService + ) { } ngOnInit(): void { - if (this.isProduction){ + if (this.isProduction) { if (this.azureAdB2CService.isLogin()) { this.userName = this.azureAdB2CService.getName(); this.userEmail = this.azureAdB2CService.getUserEmail(); this.azureAdB2CService.setTenantId(); } - }else{ + } else { if (this.loginService.isLogin()) { this.userName = this.loginService.getName(); this.userEmail = this.loginService.getUserEmail(); this.azureAdB2CService.setTenantId(); } } + this.userPhoto = localStorage.getItem('googleUserPhoto'); } }