From 75517d48214f7c4d92ba92305f7948f0d44a796a Mon Sep 17 00:00:00 2001 From: Art Date: Tue, 28 Sep 2021 15:05:52 +0300 Subject: [PATCH] 27.3.2. Modified endpoint `update user` - use userId instead of current username - frontend (#27) --- .../src/app/component/user/user.component.ts | 5 +++-- support-portal-frontend/src/app/service/user.service.ts | 5 ++--- support-portal-frontend/src/environments/environment.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/support-portal-frontend/src/app/component/user/user.component.ts b/support-portal-frontend/src/app/component/user/user.component.ts index b353c1b..1ac8c29 100644 --- a/support-portal-frontend/src/app/component/user/user.component.ts +++ b/support-portal-frontend/src/app/component/user/user.component.ts @@ -155,7 +155,7 @@ export class UserComponent implements OnInit, OnDestroy { public onUpdateUser(): void { const formData = this.userService.createUserFormData(this.currentUsername, this.editUser, this.profileImage); - this.subs.sink = this.userService.updateUser(formData) + this.subs.sink = this.userService.updateUser(this.editUser.userId, formData) .subscribe( (user: User) => { this.clickButton('closeEditUserButton'); @@ -204,6 +204,7 @@ export class UserComponent implements OnInit, OnDestroy { onUpdateCurrentUser(user: User) { this.currentUsername = this.authenticationService.getUserFromLocalStorage().username; + const userId = this.authenticationService.getUserFromLocalStorage().userId; this.refreshing = true; if (user.role == undefined) user.role = this.loggedInUser.role; @@ -214,7 +215,7 @@ export class UserComponent implements OnInit, OnDestroy { console.log(this.loggedInUser); const formData = this.userService.createUserFormData(this.currentUsername, user, this.profileImage); - this.subs.sink = this.userService.updateUser(formData) + this.subs.sink = this.userService.updateUser(userId, formData) .subscribe( (user: User) => { this.authenticationService.addUserToLocalStorage(user); diff --git a/support-portal-frontend/src/app/service/user.service.ts b/support-portal-frontend/src/app/service/user.service.ts index 2c9680d..2fc5c26 100644 --- a/support-portal-frontend/src/app/service/user.service.ts +++ b/support-portal-frontend/src/app/service/user.service.ts @@ -26,10 +26,9 @@ export class UserService { .post(`${this.host}/user/add`, formData); } - public updateUser(formData: FormData): Observable { - let currentUsername = formData.get(`currentUsername`); + public updateUser(userId: string, formData: FormData): Observable { return this.httpClient - .put(`${this.host}/user/${currentUsername}`, formData); + .put(`${this.host}/user/${userId}`, formData); } public resetPassword(email: string): Observable { diff --git a/support-portal-frontend/src/environments/environment.ts b/support-portal-frontend/src/environments/environment.ts index bacb4d1..2b9c294 100644 --- a/support-portal-frontend/src/environments/environment.ts +++ b/support-portal-frontend/src/environments/environment.ts @@ -4,12 +4,12 @@ export const environment = { production: false, - apiUrl: 'https://dockerapp.shyshkin.net', + // apiUrl: 'https://dockerapp.shyshkin.net', // apiUrl: 'https://portal-back-secure.shyshkin.net', // apiUrl: 'http://portal-bean.shyshkin.net', // apiUrl: 'http://supportportalbackend-env.eba-wfr5wya3.eu-north-1.elasticbeanstalk.com', // apiUrl: 'http://support-portal.shyshkin.net:5000', - // apiUrl: 'http://localhost:8080', + apiUrl: 'http://localhost:8080', publicUrls: ['/user/login', '/user/register', '/user/*/image/**', '/user/image/**'] };