Added redirect after user credentials change

This commit is contained in:
Max W. 2024-06-01 13:41:26 +02:00
parent 77202de315
commit 4977dbe98a
3 changed files with 14 additions and 5 deletions

View File

@ -15,7 +15,7 @@
<div class="stat">
<div class="stat-title">Total File Size on Disk</div>
<div class="stat-value">{{ totalFileSizeOnDisk | formatFileSizePipe }}</div>
<div class="stat-desc">Across all files</div>
<div class="stat-desc">Across all stored files</div>
</div>
</div>
@ -59,7 +59,7 @@
</svg>
User Management
</button>
<button class="btn btn-neutral">
<button class="btn btn-neutral" (click)="logout()">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M6 12.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-8a.5.5 0 0 0-.5.5v2a.5.5 0 0 1-1 0v-2A1.5 1.5 0 0 1 6.5 2h8A1.5 1.5 0 0 1 16 3.5v9a1.5 1.5 0 0 1-1.5 1.5h-8A1.5 1.5 0 0 1 5 12.5v-2a.5.5 0 0 1 1 0z"/>
<path fill-rule="evenodd" d="M.146 8.354a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L1.707 7.5H10.5a.5.5 0 0 1 0 1H1.707l2.147 2.146a.5.5 0 0 1-.708.708z"/>

View File

@ -44,9 +44,10 @@ export class AdminuiComponent {
async init() {
this.username = await firstValueFrom(this.authStore.username$);
await this.verifyToken();
setInterval(() => {
this.verifyToken();
}, 1000);
}, 5000);
}
async verifyToken() {
@ -81,6 +82,12 @@ export class AdminuiComponent {
this.edit_user_modal?.nativeElement.showModal();
}
logout() {
this.authStore.setToken("");
this.authStore.setUsername("");
this.router.navigate(['/login']);
}
async fetchFileUploads() {
try {
const response = await axios({

View File

@ -4,6 +4,7 @@ import axios from "axios";
import {firstValueFrom} from "rxjs";
import {DevelopmentStore} from "../../../store/DevelopmentStore";
import {AuthStore} from "../../../store/authStore";
import {Router} from "@angular/router";
@Component({
selector: 'app-edituser',
@ -21,7 +22,7 @@ export class EdituserComponent {
newPassword: string = "";
confirmNewPassword: string = "";
constructor(private developmentStore: DevelopmentStore, private authStore: AuthStore) {}
constructor(private developmentStore: DevelopmentStore, private authStore: AuthStore, private router: Router) {}
async saveUser() {
@ -46,8 +47,9 @@ export class EdituserComponent {
newPasswordConfirm: this.confirmNewPassword
}
});
// TODO: Implement backend logic for this
console.log("User updated successfully");
alert("User updated successfully. Please log in again to continue.");
await this.router.navigate(['/login']);
} catch (error) {
console.error(error);
}