Change user password integration
parent
60c4d61fcf
commit
c3027e3f6e
|
@ -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>
|
||||
|
|
|
@ -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!")
|
||||
});
|
||||
}); */
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue