Skip to content

Commit 3460566

Browse files
committed
feat: TT-577 get profile pic from Google account
1 parent bf8977e commit 3460566

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class=" py-8 flex items-center pl-3">
2-
<img src="assets/icons/user.svg" alt="user-icon" width="40" height="40"/>
2+
<img src="{{ userPhoto }}" alt="user-icon" class="round"/>
33
<span class="pl-1">
4-
<h2 class="font-poppins text-base font-semibold pl-2 dark:text-whiteTW">{{userName}}</h2>
5-
<p class="font-poppins mt-1 text-xs font-medium pl-2 text-grayTW dark:text-whiteTW">{{userEmail}}</p>
4+
<h2 class="font-poppins text-base font-semibold pl-2 dark:text-whiteTW">{{ userName }}</h2>
5+
<p class="font-poppins mt-1 text-xs font-medium pl-2 text-grayTW dark:text-whiteTW">{{ userEmail }}</p>
66
</span>
7-
</div>
7+
</div>

src/app/modules/shared/components/user/user.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
@import '../../../../../styles/colors.scss';
22

3+
.round {
4+
width:40px;
5+
height:40px;
6+
border-radius:150px;
7+
}
8+
39
.user-profile {
410
color: black;
511
cursor: pointer;

src/app/modules/shared/components/user/user.component.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,46 @@ import { Component, OnInit } from '@angular/core';
22
import { environment } from 'src/environments/environment';
33
import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
44
import { 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
})
1113
export 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

Comments
 (0)