Change user password integration
parent
60c4d61fcf
commit
c3027e3f6e
|
@ -1,7 +1,7 @@
|
||||||
<div class="sidebar" [class.visible]="isVisible">
|
<div class="sidebar" [class.visible]="isVisible">
|
||||||
<div class="sidebar-content">
|
<div class="sidebar-content">
|
||||||
<h4>Bienvenido {{username}}</h4>
|
<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>
|
<button mat-flat-button color="accent" routerLink="/admin" *ngIf="isSuperAdmin">Admin</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,17 +12,17 @@ import { ChangePasswordModalComponent } from '../../pages/admin/users/users/chan
|
||||||
export class SidebarComponent {
|
export class SidebarComponent {
|
||||||
@Input() isVisible: boolean = false;
|
@Input() isVisible: boolean = false;
|
||||||
isSuperAdmin: boolean = false;
|
isSuperAdmin: boolean = false;
|
||||||
username: string = localStorage.getItem('username') ?? '';
|
username: string = "";
|
||||||
|
decodedToken: any = "";
|
||||||
constructor(public dialog: MatDialog) {}
|
constructor(public dialog: MatDialog) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const token = localStorage.getItem('loginToken');
|
const token = localStorage.getItem('loginToken');
|
||||||
if (token) {
|
if (token) {
|
||||||
try {
|
try {
|
||||||
const decodedToken: any = jwtDecode(token);
|
this.decodedToken = jwtDecode(token);
|
||||||
console.log('Decoded JWT:', decodedToken);
|
this.isSuperAdmin = this.decodedToken.roles.includes('ROLE_SUPER_ADMIN');
|
||||||
this.isSuperAdmin = decodedToken.roles.includes('ROLE_SUPER_ADMIN');
|
this.username = this.decodedToken.username;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error decoding JWT:', error);
|
console.error('Error decoding JWT:', error);
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,10 @@ export class SidebarComponent {
|
||||||
editUser(user: any) {
|
editUser(user: any) {
|
||||||
// Implementar la lógica de edición
|
// Implementar la lógica de edición
|
||||||
const dialogRef = this.dialog.open(ChangePasswordModalComponent, {
|
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!")
|
console.log("User edited successfully!")
|
||||||
});
|
}); */
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue