Added user edit logic

This commit is contained in:
2024-06-01 12:54:36 +02:00
parent fb4d47b7bf
commit 77202de315
7 changed files with 64 additions and 9 deletions

View File

@ -29,7 +29,7 @@
Confirm new password
</label>
<input class="input w-full shadow text-center" id="password3" type="password" placeholder="********" name="newPasswordConfirm"
[(ngModel)]="confirmPassword">
[(ngModel)]="confirmNewPassword">
</div>
<div class="modal-action">

View File

@ -19,13 +19,13 @@ export class EdituserComponent {
username: string = "";
originalPassword: string = "";
newPassword: string = "";
confirmPassword: string = "";
confirmNewPassword: string = "";
constructor(private developmentStore: DevelopmentStore, private authStore: AuthStore) {}
async saveUser() {
if(this.newPassword !== this.confirmPassword) {
if(this.newPassword !== this.confirmNewPassword) {
alert("New password and confirm password do not match");
return;
}
@ -33,16 +33,17 @@ export class EdituserComponent {
try {
const response = await axios({
method: 'post',
url: this.developmentStore.getBaseUrl() + 'api/v1/secure/user/update',
url: this.developmentStore.getBaseUrl() + 'api/v1/secure/users',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + await firstValueFrom(this.authStore.token$)
},
data: {
originalUsername: this.parsedUsername,
username: this.username,
originalPassword: this.originalPassword,
newPassword: this.newPassword,
confirmPassword: this.confirmPassword
newPasswordConfirm: this.confirmNewPassword
}
});
// TODO: Implement backend logic for this