Location:
diff --git a/Client/src/app/components/members/member-edit/member-edit.component.ts b/Client/src/app/components/members/member-edit/member-edit.component.ts
index d0bead1..10770fa 100644
--- a/Client/src/app/components/members/member-edit/member-edit.component.ts
+++ b/Client/src/app/components/members/member-edit/member-edit.component.ts
@@ -21,6 +21,7 @@ export class MemberEditComponent implements OnInit {
}
user: User;
+ photoUrl: string;
constructor(
private route: ActivatedRoute,
@@ -33,6 +34,8 @@ export class MemberEditComponent implements OnInit {
this.route.data.subscribe(data => {
this.user = data['user'];
});
+
+ this.authService.currentPhotoUrl.subscribe(photoUrl => this.photoUrl = photoUrl);
}
updateUser() {
diff --git a/Client/src/app/components/members/photo-editor/photo-editor.component.ts b/Client/src/app/components/members/photo-editor/photo-editor.component.ts
index 3293753..bd518fc 100644
--- a/Client/src/app/components/members/photo-editor/photo-editor.component.ts
+++ b/Client/src/app/components/members/photo-editor/photo-editor.component.ts
@@ -66,8 +66,9 @@ export class PhotoEditorComponent implements OnInit {
this.currentMainPhoto = this.photos.filter(p => p.isMain)[0];
this.currentMainPhoto.isMain = false;
photo.isMain = true;
- this.getMemberPhotoChange.emit(photo.url);
-
+ this.authService.changeProfilePhoto(photo.url);
+ this.authService.currentUser.photoUrl = photo.url;
+ localStorage.setItem('user', JSON.stringify(this.authService.currentUser))
}, error => {
this.alertify.error(error);
})
diff --git a/Client/src/app/components/nav-menu/nav-menu.component.html b/Client/src/app/components/nav-menu/nav-menu.component.html
index c89a34b..17de2d1 100644
--- a/Client/src/app/components/nav-menu/nav-menu.component.html
+++ b/Client/src/app/components/nav-menu/nav-menu.component.html
@@ -16,7 +16,7 @@
-
+
Welcome {{ authService.decodedToken?.unique_name | titlecase }}
diff --git a/Client/src/app/components/nav-menu/nav-menu.component.ts b/Client/src/app/components/nav-menu/nav-menu.component.ts
index 9c9c30e..88525a4 100644
--- a/Client/src/app/components/nav-menu/nav-menu.component.ts
+++ b/Client/src/app/components/nav-menu/nav-menu.component.ts
@@ -10,10 +10,13 @@ import { Router } from '@angular/router';
})
export class NavMenuComponent implements OnInit {
model: any = {};
+ photoUrl: string;
constructor(public authService: AuthService, private alertify: AlertifyService, private router: Router) { }
- ngOnInit() { }
+ ngOnInit() {
+ this.authService.currentPhotoUrl.subscribe(photoUrl => this.photoUrl = photoUrl);
+ }
login() {
this.authService.login(this.model).subscribe(next => {
diff --git a/Client/src/app/services/auth.service.ts b/Client/src/app/services/auth.service.ts
index 628136f..154bf8b 100644
--- a/Client/src/app/services/auth.service.ts
+++ b/Client/src/app/services/auth.service.ts
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
-import { Observable } from 'rxjs';
+import { Observable, BehaviorSubject } from 'rxjs';
import { JwtHelperService } from '@auth0/angular-jwt'
import { User } from '../models/user';
@@ -16,6 +16,8 @@ export class AuthService {
public currentUser: User;
public decodedToken: any;
+ public photoUrl = new BehaviorSubject('../../assets/placeholder.png');
+ public currentPhotoUrl = this.photoUrl.asObservable();
constructor(private http: HttpClient) { }
@@ -29,6 +31,7 @@ export class AuthService {
localStorage.setItem('user', JSON.stringify(user.userResource));
this.decodedToken = this.jwtHelper.decodeToken(user.token);
this.currentUser = user.userResource;
+ this.changeProfilePhoto(this.currentUser.photoUrl);
}
})
);
@@ -42,4 +45,8 @@ export class AuthService {
const token = localStorage.getItem('token');
return !this.jwtHelper.isTokenExpired(token);
}
+
+ changeProfilePhoto(photoUrl: string) {
+ this.photoUrl.next(photoUrl);
+ }
}
diff --git a/Client/src/assets/placeholder.png b/Client/src/assets/placeholder.png
new file mode 100644
index 0000000..7640e01
Binary files /dev/null and b/Client/src/assets/placeholder.png differ