Change user password integration

pull/3/head
Alvaro Puente Mella 2024-06-13 12:55:38 +02:00
parent 60c4d61fcf
commit c3027e3f6e
2 changed files with 9 additions and 9 deletions

View File

@ -1,7 +1,7 @@
<div class="sidebar" [class.visible]="isVisible">
<div class="sidebar-content">
<h4>Bienvenido {{username}}</h4>
<button mat-flat-button color="primary" (click)="editUser(username)">Editar usuario</button>
<button mat-flat-button color="primary" (click)="editUser('username')">Editar usuario</button>
<button mat-flat-button color="accent" routerLink="/admin" *ngIf="isSuperAdmin">Admin</button>
</div>
</div>

View File

@ -12,17 +12,17 @@ import { ChangePasswordModalComponent } from '../../pages/admin/users/users/chan
export class SidebarComponent {
@Input() isVisible: boolean = false;
isSuperAdmin: boolean = false;
username: string = localStorage.getItem('username') ?? '';
username: string = "";
decodedToken: any = "";
constructor(public dialog: MatDialog) {}
ngOnInit(): void {
const token = localStorage.getItem('loginToken');
if (token) {
try {
const decodedToken: any = jwtDecode(token);
console.log('Decoded JWT:', decodedToken);
this.isSuperAdmin = decodedToken.roles.includes('ROLE_SUPER_ADMIN');
this.decodedToken = jwtDecode(token);
this.isSuperAdmin = this.decodedToken.roles.includes('ROLE_SUPER_ADMIN');
this.username = this.decodedToken.username;
} catch (error) {
console.error('Error decoding JWT:', error);
}
@ -32,10 +32,10 @@ export class SidebarComponent {
editUser(user: any) {
// Implementar la lógica de edición
const dialogRef = this.dialog.open(ChangePasswordModalComponent, {
data: { user: user }
data: { user: this.decodedToken.username, uuid: this.decodedToken.uuid },
});
dialogRef.componentInstance.userEdited.subscribe(() => {
/* dialogRef.componentInstance.userEdited.subscribe(() => {
console.log("User edited successfully!")
});
}); */
}
}