27.7. Excluded current username from FormData (#27)
This commit is contained in:
@ -33,7 +33,6 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
public profileImageFileName: string | null;
|
||||
public profileImage: File | null;
|
||||
public editUser: User = new User();
|
||||
private currentUsername: string;
|
||||
|
||||
public fileUploadStatus: FileUploadStatus = new FileUploadStatus();
|
||||
|
||||
@ -97,7 +96,7 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public onAddNewUser(userForm: NgForm): void {
|
||||
let formData = this.userService.createUserFormData(null, userForm.value, this.profileImage);
|
||||
let formData = this.userService.createUserFormData(userForm.value, this.profileImage);
|
||||
this.subs.sink = this.userService.addUser(formData)
|
||||
.subscribe(
|
||||
(user: User) => {
|
||||
@ -150,12 +149,11 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
|
||||
public onEditUser(user: User): void {
|
||||
this.editUser = user;
|
||||
this.currentUsername = user.username;
|
||||
this.clickButton('openUserEdit');
|
||||
}
|
||||
|
||||
public onUpdateUser(): void {
|
||||
const formData = this.userService.createUserFormData(this.currentUsername, this.editUser, this.profileImage);
|
||||
const formData = this.userService.createUserFormData(this.editUser, this.profileImage);
|
||||
this.subs.sink = this.userService.updateUser(this.editUser.userId, formData)
|
||||
.subscribe(
|
||||
(user: User) => {
|
||||
@ -204,7 +202,6 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
onUpdateCurrentUser(user: User) {
|
||||
this.currentUsername = this.authenticationService.getUserFromLocalStorage().username;
|
||||
const userId = this.authenticationService.getUserFromLocalStorage().userId;
|
||||
this.refreshing = true;
|
||||
|
||||
@ -212,10 +209,7 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
if (user.active == undefined) user.active = this.loggedInUser.active;
|
||||
if (user.notLocked == undefined) user.notLocked = this.loggedInUser.notLocked;
|
||||
|
||||
console.log(user);
|
||||
console.log(this.loggedInUser);
|
||||
|
||||
const formData = this.userService.createUserFormData(this.currentUsername, user, this.profileImage);
|
||||
const formData = this.userService.createUserFormData(user, this.profileImage);
|
||||
this.subs.sink = this.userService.updateUser(userId, formData)
|
||||
.subscribe(
|
||||
(user: User) => {
|
||||
|
||||
@ -62,12 +62,10 @@ export class UserService {
|
||||
return [];
|
||||
}
|
||||
|
||||
public createUserFormData(loggedInUsername: string | null, user: User, profileImage: File | null): FormData {
|
||||
public createUserFormData(user: User, profileImage: File | null): FormData {
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
if (loggedInUsername)
|
||||
formData.append('currentUsername', loggedInUsername);
|
||||
formData.append('firstName', user.firstName);
|
||||
formData.append('lastName', user.lastName);
|
||||
formData.append("username", user.username);
|
||||
|
||||
Reference in New Issue
Block a user