27.3.2. Modified endpoint update user - use userId instead of current username - frontend (#27)

This commit is contained in:
Art
2021-09-28 15:05:52 +03:00
parent 1046f352ab
commit 75517d4821
3 changed files with 7 additions and 7 deletions

View File

@ -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);

View File

@ -26,10 +26,9 @@ export class UserService {
.post<User>(`${this.host}/user/add`, formData);
}
public updateUser(formData: FormData): Observable<User> {
let currentUsername = formData.get(`currentUsername`);
public updateUser(userId: string, formData: FormData): Observable<User> {
return this.httpClient
.put<User>(`${this.host}/user/${currentUsername}`, formData);
.put<User>(`${this.host}/user/${userId}`, formData);
}
public resetPassword(email: string): Observable<CustomHttpResponse> {

View File

@ -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/**']
};