27.3.2. Modified endpoint update user - use userId instead of current username - frontend (#27)
This commit is contained in:
@ -155,7 +155,7 @@ export class UserComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
public onUpdateUser(): void {
|
public onUpdateUser(): void {
|
||||||
const formData = this.userService.createUserFormData(this.currentUsername, this.editUser, this.profileImage);
|
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(
|
.subscribe(
|
||||||
(user: User) => {
|
(user: User) => {
|
||||||
this.clickButton('closeEditUserButton');
|
this.clickButton('closeEditUserButton');
|
||||||
@ -204,6 +204,7 @@ export class UserComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
onUpdateCurrentUser(user: User) {
|
onUpdateCurrentUser(user: User) {
|
||||||
this.currentUsername = this.authenticationService.getUserFromLocalStorage().username;
|
this.currentUsername = this.authenticationService.getUserFromLocalStorage().username;
|
||||||
|
const userId = this.authenticationService.getUserFromLocalStorage().userId;
|
||||||
this.refreshing = true;
|
this.refreshing = true;
|
||||||
|
|
||||||
if (user.role == undefined) user.role = this.loggedInUser.role;
|
if (user.role == undefined) user.role = this.loggedInUser.role;
|
||||||
@ -214,7 +215,7 @@ export class UserComponent implements OnInit, OnDestroy {
|
|||||||
console.log(this.loggedInUser);
|
console.log(this.loggedInUser);
|
||||||
|
|
||||||
const formData = this.userService.createUserFormData(this.currentUsername, user, this.profileImage);
|
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(
|
.subscribe(
|
||||||
(user: User) => {
|
(user: User) => {
|
||||||
this.authenticationService.addUserToLocalStorage(user);
|
this.authenticationService.addUserToLocalStorage(user);
|
||||||
|
|||||||
@ -26,10 +26,9 @@ export class UserService {
|
|||||||
.post<User>(`${this.host}/user/add`, formData);
|
.post<User>(`${this.host}/user/add`, formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateUser(formData: FormData): Observable<User> {
|
public updateUser(userId: string, formData: FormData): Observable<User> {
|
||||||
let currentUsername = formData.get(`currentUsername`);
|
|
||||||
return this.httpClient
|
return this.httpClient
|
||||||
.put<User>(`${this.host}/user/${currentUsername}`, formData);
|
.put<User>(`${this.host}/user/${userId}`, formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public resetPassword(email: string): Observable<CustomHttpResponse> {
|
public resetPassword(email: string): Observable<CustomHttpResponse> {
|
||||||
|
|||||||
@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
apiUrl: 'https://dockerapp.shyshkin.net',
|
// apiUrl: 'https://dockerapp.shyshkin.net',
|
||||||
// apiUrl: 'https://portal-back-secure.shyshkin.net',
|
// apiUrl: 'https://portal-back-secure.shyshkin.net',
|
||||||
// apiUrl: 'http://portal-bean.shyshkin.net',
|
// apiUrl: 'http://portal-bean.shyshkin.net',
|
||||||
// apiUrl: 'http://supportportalbackend-env.eba-wfr5wya3.eu-north-1.elasticbeanstalk.com',
|
// apiUrl: 'http://supportportalbackend-env.eba-wfr5wya3.eu-north-1.elasticbeanstalk.com',
|
||||||
// apiUrl: 'http://support-portal.shyshkin.net:5000',
|
// apiUrl: 'http://support-portal.shyshkin.net:5000',
|
||||||
// apiUrl: 'http://localhost:8080',
|
apiUrl: 'http://localhost:8080',
|
||||||
publicUrls: ['/user/login', '/user/register', '/user/*/image/**', '/user/image/**']
|
publicUrls: ['/user/login', '/user/register', '/user/*/image/**', '/user/image/**']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user