فهرست منبع

Finalización de las políticas de seguridad

Jose Brito 2 سال پیش
والد
کامیت
ccec429780

+ 3 - 23
sistema-mantenimiento-front/src/app/app-routing.module.ts

@@ -1,3 +1,4 @@
+import { SecurityPoliticsComponent } from './components/system-admin/security-politics/security-politics.component';
 import { EquipmentManagementComponent } from './components/equipment-management/equipment-management.component';
 import { NewAdviceComponent } from './components/system-admin/advices/new-advice/new-advice.component';
 import { AdvicesComponent } from './components/system-admin/advices/advices.component';
@@ -22,8 +23,6 @@ import { NgModule } from '@angular/core';
 import { RouterModule, Routes } from '@angular/router';
 import { LoginGuard } from './guards/login.guard';
 import { AuthGuard } from './guards/auth.guard';
-import { GETBFOComponent } from './components/getb/getbfo/getbfo.component';
-import { GETBFOFORMComponent } from './components/getb/getbfo/getbfo-form/getbfo-form.component';
 
 // import { GETBFOUPDATEComponent } from './components/getb/getbfo/getbfo-update/getbfo-update.component';
 
@@ -31,12 +30,6 @@ import { Plantilla1Component } from './components/test/plantilla1/plantilla1.com
 import { Plantilla2Component } from './components/test/plantilla2/plantilla2.component';
 import { Plantilla3Component } from './components/test/plantilla3/plantilla3.component';
 
-import { GETBGMComponent } from './components/getb/getbgm/getbgm.component';
-import { GETBSBComponent } from './components/getb/getbsb/getbsb.component';
-import { GETBMEComponent } from './components/getb/getbme/getbme.component';
-import { GetbtbComponent } from './components/getb/getbtb/getbtb.component';
-import { GETBTBFORMComponent } from './components/getb/getbtb/getbtb-form/getbtb-form.component';
-
 // Módulo: Gestión de Adquisiciones //
 import { MGADComponent } from './components/mgad/mgad.component';
 import { SMADComponent } from './components/mgad/smad/smad.component';
@@ -113,10 +106,7 @@ import { WorkflowAdvanceComponent } from './components/samwf-user/workflow-advan
 import { WorkflowHistoryNotificationComponent } from './components/samwf-user/workflow-history-notification/workflow-history-notification.component';
 import { TasksModuleComponent } from './components/samwf/tasks-module/tasks-module.component';
 import { WorkflowAdminAdvanceComponent } from './components/samwf/workflow-admin-advance/workflow-admin-advance.component';
-import { GETBGTFORMComponent } from './components/getb/getbgt/getbgt-form/getbgt-form.component';
-import { GetbgtComponent } from './components/getb/getbgt/getbgt.component';
 // import { GETBFOCreateComponent } from './components/getb/getbfo/getbfo-create/getbfo-create.component';
-import { GetbtbFormEditComponent } from './components/getb/getbtb/getbtb-form-edit/getbtb-form-edit.component';
 import { WorkflowTaskFormEditComponent } from './components/samwf/workflow-detail/workflow-task-form-edit/workflow-task-form-edit.component';
 import { AdquiComponent } from './components/geadq/acquisition/acquisition.component';
 import { PurchaseLineComponent } from './components/geadq/acquisition/purchase-line/purchase-line.component';
@@ -155,7 +145,8 @@ const routes: Routes = [
       { path: 'ADSI/SAUS/detalles', component: DetailsComponent},            //Detalles de las acciones de los usuarios
       { path: 'ADSI/CRAV', component: AdvicesComponent},                     //Historial de avisos registrados
       { path: 'ADSI/CRAV/nuevo', component: NewAdviceComponent},             //Creación de avisos nuevos
-      { path: 'ADSI/CRAV/editar', component: NewAdviceComponent},             //Edición de avisos
+      { path: 'ADSI/CRAV/editar', component: NewAdviceComponent},            //Edición de avisos
+      { path: 'ADSI/POSE', component: SecurityPoliticsComponent},                   //Políticas de seguridad
       { path: 'ADSI/ADGLCA', component: CataloguesComponent},
       { path: 'ADSI/ADMCAT/lector', component: CatalogueViewerComponent},
       { path: 'ADSI/CREAVI', component: AdvicesComponent },
@@ -174,23 +165,12 @@ const routes: Routes = [
       //Rutas módulo usuarios y perfiles
       { path: 'users-profiles', component: UsersProfilesComponent },
       //Rutas módulo gestión de adquisiciones
-      { path: 'getbfo', component: GETBFOComponent },
-      { path: 'getbfo-create', component: GETBFOFORMComponent },
-      { path: 'getbfo-update/:id', component: GETBFOFORMComponent },
       //Rutas módulo workflow
       //Rutas módulo administrador del sistema
-      { path: 'getbgm', component: GETBGMComponent },
-      { path: 'getbsb', component: GETBSBComponent },
-      { path: 'getbme', component: GETBMEComponent },
-      { path: 'getbtb', component: GetbtbComponent },
-      { path: 'getbtb-create', component: GETBTBFORMComponent },
-      { path: 'getbtb-edit/:id', component: GetbtbFormEditComponent },
 
       { path: 'template-menu', component: Plantilla1Component },
       { path: 'template-table', component: Plantilla2Component },
       { path: 'template-form', component: Plantilla3Component },
-      { path: 'getbgt', component: GetbgtComponent },
-      { path: 'getbgt-form', component: GETBGTFORMComponent },
 
       { path: 'mgad', component: MGADComponent },
       // Adquisiciones

+ 2 - 0
sistema-mantenimiento-front/src/app/app.module.ts

@@ -256,6 +256,7 @@ import { ConfirmOrderComponent } from './components/geadq/dispatch/order-recepti
 import { ShoppingCartComponent } from './components/geadq/acquisition/purchase-line/shopping-cart/shopping-cart.component';
 import { AdviceAlertComponent } from './components/template/advice-alert/advice-alert.component';
 import { DetailsArtitleComponent } from './components/geadq/provider/artitle/details-artitle/details-artitle.component';
+import { SecurityPoliticsComponent } from './components/system-admin/security-politics/security-politics.component';
 
 @NgModule({
   declarations: [
@@ -418,6 +419,7 @@ import { DetailsArtitleComponent } from './components/geadq/provider/artitle/det
     GETBFONEWFORMComponent,
     GetbfoAddconditionComponent,
     GETBFOUSERSDATESComponent,
+    SecurityPoliticsComponent,
   ],
   imports: [
     MatRippleModule,

+ 1 - 1
sistema-mantenimiento-front/src/app/components/login/login.component.html

@@ -21,7 +21,7 @@
                             </button>
                         </mat-form-field>
                         <div class="mt-16">
-                            <button mat-raised-button class="btn-login"
+                            <button mat-raised-button class="pink_primary_background white_font"
                                 matTooltip="Iniciar Sesion" (click)="login()" tabindex="3">
                                 Iniciar sesión
                             </button>

+ 28 - 0
sistema-mantenimiento-front/src/app/components/system-admin/security-politics/security-politics.component.css

@@ -0,0 +1,28 @@
+.form-pass-container{
+    display: flex;
+    flex-direction: row;
+    flex-wrap: wrap;
+    justify-content: space-around;
+    height: calc(100vh - 284px);
+}
+
+.auth-table-container{
+    height: calc(100vh - 284px);
+}
+
+.element{
+    margin: 16px;
+    width: 256px;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+}
+
+.save-politics-container{
+    width: 100%;
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+}

+ 182 - 0
sistema-mantenimiento-front/src/app/components/system-admin/security-politics/security-politics.component.html

@@ -0,0 +1,182 @@
+<div class="items-container">
+    <div id="navigation" class="mb-8">
+        <div class="prev-page prevent-select indigo_primary_background mat-elevation-z8" (click)="goBack(1)" matRipple>
+            <mat-icon style="color: white;">arrow_back</mat-icon>
+            <div class="page-name ml-4">Administrador del sistema</div>
+        </div>
+    </div>
+    <mat-card class="elevation-z8" style="width: 100%; height: 100%;">
+        <mat-card-title style="text-align: center;" class="prevent-select">Políticas de seguridad</mat-card-title>
+        <mat-card-content>
+            <div class="loader-container prevent-select" *ngIf="isLoading">
+                <mat-spinner></mat-spinner>
+                <h2 class="loader-label">Cargando...</h2>
+            </div>
+            <div class="error-container prevent-select" *ngIf="!isLoading && hasError">
+                <mat-icon style="color: #e53935; transform: scale(5); margin: 48px;">error</mat-icon>
+                <h1 style="color: #e53935;">¡Error!</h1>
+                <p style="font-style: italic; font-size: 16px; overflow-wrap: anywhere; text-align: center;">{{ errorStr }}</p>
+            </div>
+            <div class="table-container" [hidden]="!(!isLoading && !hasError)" style="overflow: hidden;">
+                <mat-tab-group class="prevent-select">
+                    <mat-tab label="Patrón de contraseñas">
+                        <div class="form-pass-container" [formGroup]="politicsForm">
+                            <div class="element">
+                                <mat-checkbox [disabled]="true" checked>Longitud mínima</mat-checkbox>
+                                <mat-form-field appearance="fill" style="width: 100%;">
+                                    <input matInput style="text-align: center;" readonly formControlName="minLength">
+                                    <button mat-icon-button matPrefix (click)="editMinLength(0)">
+                                        <mat-icon>remove</mat-icon>
+                                    </button>
+                                    <button mat-icon-button matSuffix (click)="editMinLength(1)">
+                                        <mat-icon>add</mat-icon>
+                                    </button>
+                                </mat-form-field>
+                            </div>
+                            <div class="element">
+                                <mat-checkbox formControlName="enableUpperCase" (change)="disableMinUpper()">Letras mayúsculas</mat-checkbox>
+                                <mat-form-field appearance="fill" style="width: 100%;">
+                                    <input matInput style="text-align: center;" readonly formControlName="minUpper">
+                                    <button mat-icon-button matPrefix (click)="editMinUpper(0)">
+                                        <mat-icon>remove</mat-icon>
+                                    </button>
+                                    <button mat-icon-button matSuffix (click)="editMinUpper(1)">
+                                        <mat-icon>add</mat-icon>
+                                    </button>
+                                </mat-form-field>
+                            </div>
+                            <div class="element">
+                                <mat-checkbox formControlName="enableNumbers" (change)="disableMinNumber()">Números</mat-checkbox>
+                                <mat-form-field appearance="fill" style="width: 100%;">
+                                    <input matInput style="text-align: center;" readonly formControlName="minNumber">
+                                    <button mat-icon-button matPrefix (click)="editMinNumber(0)">
+                                        <mat-icon>remove</mat-icon>
+                                    </button>
+                                    <button mat-icon-button matSuffix (click)="editMinNumber(1)">
+                                        <mat-icon>add</mat-icon>
+                                    </button>
+                                </mat-form-field>
+                            </div>
+                            <div class="element">
+                                <mat-checkbox formControlName="enableCharacters" (change)="disableMinCharacters()">Caracteres especiales</mat-checkbox>
+                                <mat-form-field appearance="fill" style="width: 100%;">
+                                    <input matInput style="text-align: center;" readonly formControlName="minCharacters">
+                                    <button mat-icon-button matPrefix (click)="editMinCharacters(0)">
+                                        <mat-icon>remove</mat-icon>
+                                    </button>
+                                    <button mat-icon-button matSuffix (click)="editMinCharacters(1)">
+                                        <mat-icon>add</mat-icon>
+                                    </button>
+                                </mat-form-field>
+                            </div>
+                            <div class="save-politics-container">
+                                <button mat-flat-button class="indigo_primary_background white_font" (click)="savePaswordFormat()">Guardar configuración</button>
+                            </div>
+                        </div>
+                    </mat-tab>
+                    <mat-tab label="Duración de sesiones">
+                        <div class="form-pass-container" [formGroup]="sessionsForm">
+                            <div class="element">
+                                <mat-label>Días</mat-label>
+                                <mat-form-field appearance="fill" style="width: 100%;">
+                                    <input matInput style="text-align: center;" readonly formControlName="days">
+                                    <button mat-icon-button matPrefix (click)="editDays(0)">
+                                        <mat-icon>remove</mat-icon>
+                                    </button>
+                                    <button mat-icon-button matSuffix (click)="editDays(1)">
+                                        <mat-icon>add</mat-icon>
+                                    </button>
+                                </mat-form-field>
+                            </div>
+                            <div class="element">
+                                <mat-label>Horas</mat-label>
+                                <mat-form-field appearance="fill" style="width: 100%;">
+                                    <input matInput style="text-align: center;" readonly formControlName="hours">
+                                    <button mat-icon-button matPrefix (click)="editHours(0)">
+                                        <mat-icon>remove</mat-icon>
+                                    </button>
+                                    <button mat-icon-button matSuffix (click)="editHours(1)">
+                                        <mat-icon>add</mat-icon>
+                                    </button>
+                                </mat-form-field>
+                            </div>
+                            <div class="element">
+                                <mat-label>Minutos</mat-label>
+                                <mat-form-field appearance="fill" style="width: 100%;">
+                                    <input matInput style="text-align: center;" readonly formControlName="minutes">
+                                    <button mat-icon-button matPrefix (click)="editMinutes(0)">
+                                        <mat-icon>remove</mat-icon>
+                                    </button>
+                                    <button mat-icon-button matSuffix (click)="editMinutes(1)">
+                                        <mat-icon>add</mat-icon>
+                                    </button>
+                                </mat-form-field>
+                            </div>
+                            <div class="element">
+                                <mat-label>Segundos</mat-label>
+                                <mat-form-field appearance="fill" style="width: 100%;">
+                                    <input matInput style="text-align: center;" readonly formControlName="seconds">
+                                    <button mat-icon-button matPrefix (click)="editSeconds(0)">
+                                        <mat-icon>remove</mat-icon>
+                                    </button>
+                                    <button mat-icon-button matSuffix (click)="editSeconds(1)">
+                                        <mat-icon>add</mat-icon>
+                                    </button>
+                                </mat-form-field>
+                            </div>
+                            <div class="save-politics-container">
+                                <button mat-flat-button class="indigo_primary_background white_font" (click)="saveSessionsDuration()">Guardar configuración</button>
+                            </div>
+                        </div>
+                    </mat-tab>
+                    <mat-tab label="Autenticación en dos pasos">
+                        <div class="auth-table-container prevent-select">
+                            <table mat-table [dataSource]="dataSourceAuth!">
+                                <ng-container matColumnDef="ID">
+                                    <th mat-header-cell *matHeaderCellDef>ID</th>
+                                    <td mat-cell *matCellDef="let row"> {{row.IDUSUARIO}} </td>
+                                </ng-container>
+                                
+                                <ng-container matColumnDef="NAME">
+                                    <th mat-header-cell *matHeaderCellDef>Usuario</th>
+                                    <td mat-cell *matCellDef="let row"> {{row.NOMBREUSUARIO}} </td>
+                                </ng-container>
+                                
+                                <ng-container matColumnDef="AUTH">
+                                    <th mat-header-cell *matHeaderCellDef>Usar autorización</th>
+                                    <td mat-cell *matCellDef="let row; let i = index">
+                                        <mat-slide-toggle (change)="changeStatus(i)" [checked]="row.AUTHENABLED">
+                                            {{ row.AUTHENABLED ? 'Activado' : 'Desactivado' }}
+                                        </mat-slide-toggle>
+                                    </td>
+                                </ng-container>
+    
+                                <tr mat-header-row *matHeaderRowDef="displayedColumnsAuth"></tr>
+                                <tr mat-row *matRowDef="let row; columns: displayedColumnsAuth;"></tr>
+                            </table>
+                        </div>
+                    </mat-tab>
+                    <mat-tab label="Número de sesiones activas">
+                        <div class="form-pass-container" [formGroup]="sessionsNumberForm">
+                            <div class="element">
+                                <mat-label>Sesiones configuradas</mat-label>
+                                <mat-form-field appearance="fill" style="width: 100%;">
+                                    <input matInput style="text-align: center;" readonly formControlName="number">
+                                    <button mat-icon-button matPrefix (click)="editNumber(0)">
+                                        <mat-icon>remove</mat-icon>
+                                    </button>
+                                    <button mat-icon-button matSuffix (click)="editNumber(1)">
+                                        <mat-icon>add</mat-icon>
+                                    </button>
+                                </mat-form-field>
+                            </div>
+                            <div class="save-politics-container">
+                                <button mat-flat-button class="indigo_primary_background white_font" (click)="saveActiveSessionsNumber()">Guardar configuración</button>
+                            </div>
+                        </div>
+                    </mat-tab>
+                </mat-tab-group>
+            </div>
+        </mat-card-content>
+    </mat-card>
+</div>

+ 25 - 0
sistema-mantenimiento-front/src/app/components/system-admin/security-politics/security-politics.component.spec.ts

@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { SecurityPoliticsComponent } from './security-politics.component';
+
+describe('SecurityPoliticsComponent', () => {
+  let component: SecurityPoliticsComponent;
+  let fixture: ComponentFixture<SecurityPoliticsComponent>;
+
+  beforeEach(async () => {
+    await TestBed.configureTestingModule({
+      declarations: [ SecurityPoliticsComponent ]
+    })
+    .compileComponents();
+  });
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(SecurityPoliticsComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 524 - 0
sistema-mantenimiento-front/src/app/components/system-admin/security-politics/security-politics.component.ts

@@ -0,0 +1,524 @@
+import { ActiveSessionsNumberResponse } from './../../../interfaces/active-sessions-number.interface';
+import { SessionsDurationsInterface } from './../../../interfaces/sessions-duration.interface';
+import { PasswordFormatResponse } from './../../../interfaces/password-format.interface';
+import { MatSnackBar } from '@angular/material/snack-bar';
+import { MatTableDataSource } from '@angular/material/table';
+import { UsersAuth, UserAuth } from './../../../interfaces/user-auths.interface';
+import { lastValueFrom } from 'rxjs';
+import { EncService } from './../../../services/enc/enc.service';
+import { SystemAdminService } from './../../../services/system-admin.service';
+import { FormBuilder, FormControl } from '@angular/forms';
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+  selector: 'app-security-politics',
+  templateUrl: './security-politics.component.html',
+  styleUrls: ['./security-politics.component.css']
+})
+export class SecurityPoliticsComponent implements OnInit {
+  isLoading: boolean;
+  hasError: boolean;
+  errorStr: string;
+  users: UserAuth[] = [];
+
+  politicsForm = this._formBuilder.group({
+    enableMinLength: true,
+    minLength: '8',
+    enableUpperCase: true,
+    minUpper: new FormControl({value: '1', disabled: false}),
+    enableNumbers: true,
+    minNumber: new FormControl({value: '1', disabled: false}),
+    enableCharacters: true,
+    minCharacters: new FormControl({value: '1', disabled: false})
+  });
+
+  sessionsForm = this._formBuilder.group({
+    days: '1',
+    hours: '0',
+    minutes: '0',
+    seconds: '0',
+  });
+
+  sessionsNumberForm = this._formBuilder.group({
+    number: '3',
+  });
+
+  dataSourceAuth?: MatTableDataSource<UserAuth>;
+  displayedColumnsAuth = ['ID', 'NAME', 'AUTH'];
+
+  constructor(
+    private _formBuilder: FormBuilder,
+    private _systemAdminService: SystemAdminService,
+    private _encService: EncService,
+    private _snackBar: MatSnackBar,
+  ) { 
+    this.isLoading = true;
+    this.hasError = false;
+    this.errorStr = "";
+  }
+
+  ngOnInit(): void {
+    this.getAuthData();
+  }
+
+  openSnackBar(msg: string){
+    this._snackBar.open(msg, undefined, {
+      duration: 2500
+    })
+  }
+
+  async getAuthData(){
+    try{
+      let idUser = localStorage.getItem('idusuario');
+      let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idUser!));
+      let userAuths: UsersAuth = await lastValueFrom(this._systemAdminService.getTwoStepsAuth(shortEnc.response.encrypted, 1));
+      this.users = [];
+
+      let cont = 0;
+      userAuths.response.forEach(async (item: UserAuth) => {
+        let idDec = await this._encService.desencriptar(item.IDUSUARIO);
+        let id = await this._encService.desencriptar(idUser!);
+
+        if(idDec != id){
+          let usr: UserAuth = {
+            IDUSUARIO: idDec,
+            NOMBREUSUARIO: item.NOMBREUSUARIO,
+            AUTHENABLED: item.AUTHENABLED
+          };
+
+          this.users.push(usr);
+        }
+        
+        cont++;
+        if(cont == userAuths.response.length){
+          this.dataSourceAuth = new MatTableDataSource(this.users);
+          this.getPwdData();
+        }
+      });
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        this.errorStr = error.error.msg;
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
+  }
+
+  async savePaswordFormat(){
+    try{
+      var passwordForm = new FormData();
+      let config = this.politicsForm.getRawValue();
+      let idUser = localStorage.getItem('idusuario');
+
+      passwordForm.append('id_user', idUser!);
+      passwordForm.append('linea', '1');
+      passwordForm.append('min_length', config.minLength!);
+      passwordForm.append('upper_enabled', config.enableUpperCase ? '1' : '0');
+      passwordForm.append('min_upper', config.minUpper!);
+      passwordForm.append('number_enabled', config.enableNumbers ? '1' : '0');
+      passwordForm.append('min_number', config.minNumber!);
+      passwordForm.append('chars_enabled', config.enableCharacters ? '1' : '0');
+      passwordForm.append('min_chars', config.minCharacters!);
+
+      await lastValueFrom(this._systemAdminService.savePasswordFormat(passwordForm));
+
+      this.isLoading = true;
+      this.hasError = false;
+      this.errorStr = "";
+
+      this.getAuthData();
+    }catch(error: any){
+      let msg = '';
+      if(error.error == undefined){
+        msg = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        msg = 'Ocurrió un error inesperado.';
+      }else{
+        msg = error.error.msg;
+      }
+
+      this.openSnackBar(msg);
+    }
+  }
+
+  async saveSessionsDuration(){
+    try{
+      var passwordForm = new FormData();
+      let config = this.sessionsForm.getRawValue();
+      let idUser = localStorage.getItem('idusuario');
+
+      passwordForm.append('id_user', idUser!);
+      passwordForm.append('linea', '1');
+      passwordForm.append('days', config.days!);
+      passwordForm.append('hours', config.hours!);
+      passwordForm.append('minutes', config.minutes!);
+      passwordForm.append('seconds', config.seconds!);
+
+      await lastValueFrom(this._systemAdminService.saveSessionsDuration(passwordForm));
+
+      this.isLoading = true;
+      this.hasError = false;
+      this.errorStr = "";
+
+      this.getAuthData();
+    }catch(error: any){
+      let msg = '';
+      if(error.error == undefined){
+        msg = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        msg = 'Ocurrió un error inesperado.';
+      }else{
+        msg = error.error.msg;
+      }
+
+      this.openSnackBar(msg);
+    }
+  }
+
+  async saveActiveSessionsNumber(){
+    try{
+      var passwordForm = new FormData();
+      let config = this.sessionsNumberForm.getRawValue();
+      let idUser = localStorage.getItem('idusuario');
+
+      passwordForm.append('id_user', idUser!);
+      passwordForm.append('linea', '1');
+      passwordForm.append('sessions', config.number!);
+
+      await lastValueFrom(this._systemAdminService.saveActiveSessionsNumber(passwordForm));
+
+      this.isLoading = true;
+      this.hasError = false;
+      this.errorStr = "";
+
+      this.getAuthData();
+    }catch(error: any){
+      let msg = '';
+      if(error.error == undefined){
+        msg = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        msg = 'Ocurrió un error inesperado.';
+      }else{
+        msg = error.error.msg;
+      }
+
+      this.openSnackBar(msg);
+    }
+  }
+
+  async getPwdData(){
+    try{
+      let idUser = localStorage.getItem('idusuario');
+      let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idUser!));
+      let pwdFormat: PasswordFormatResponse = await lastValueFrom(this._systemAdminService.getPasswordFormat(shortEnc.response.encrypted, 1));
+
+      this.politicsForm.controls.minLength.setValue(`${pwdFormat.response.password_format.min_length}`);
+      this.politicsForm.controls.enableUpperCase.setValue(pwdFormat.response.password_format.upper_enabled);
+      this.politicsForm.controls.minUpper.setValue(`${pwdFormat.response.password_format.min_upper}`);
+
+      if(!pwdFormat.response.password_format.upper_enabled){
+        this.politicsForm.controls.minUpper.disable();
+      }
+
+      this.politicsForm.controls.enableNumbers.setValue(pwdFormat.response.password_format.number_enabled);
+      this.politicsForm.controls.minNumber.setValue(`${pwdFormat.response.password_format.min_number}`);
+
+      if(!pwdFormat.response.password_format.number_enabled){
+        this.politicsForm.controls.minNumber.disable();
+      }
+
+      this.politicsForm.controls.enableCharacters.setValue(pwdFormat.response.password_format.chars_enabled);
+      this.politicsForm.controls.minCharacters.setValue(`${pwdFormat.response.password_format.min_chars}`);
+
+      if(!pwdFormat.response.password_format.chars_enabled){
+        this.politicsForm.controls.minCharacters.disable();
+      }
+      
+      this.getSessionsData();
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        this.errorStr = error.error.msg;
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
+  }
+
+  async getSessionsData(){
+    try{
+      let idUser = localStorage.getItem('idusuario');
+      let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idUser!));
+      let sessionsDuration: SessionsDurationsInterface = await lastValueFrom(this._systemAdminService.getSessionsDuration(shortEnc.response.encrypted, 1));
+
+      this.sessionsForm.controls.days.setValue(`${sessionsDuration.response.sessions_duration.days}`);
+      this.sessionsForm.controls.hours.setValue(`${sessionsDuration.response.sessions_duration.hours}`);
+      this.sessionsForm.controls.minutes.setValue(`${sessionsDuration.response.sessions_duration.minutes}`);
+      this.sessionsForm.controls.seconds.setValue(`${sessionsDuration.response.sessions_duration.seconds}`);
+      
+      this.getActiveSessionsNumber();
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        this.errorStr = error.error.msg;
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
+  }
+
+  async getActiveSessionsNumber(){
+    try{
+      let idUser = localStorage.getItem('idusuario');
+      let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idUser!));
+      let activeSessionsNumber: ActiveSessionsNumberResponse = await lastValueFrom(this._systemAdminService.getActiveSessionsNumber(shortEnc.response.encrypted, 1));
+
+      this.sessionsNumberForm.controls.number.setValue(`${activeSessionsNumber.response.active_sessions_number}`);
+
+      this.hasError = activeSessionsNumber.error;
+      this.errorStr = activeSessionsNumber.msg;
+      this.isLoading = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        this.errorStr = error.error.msg;
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
+  }
+
+  async changeStatus(index: number){
+    try{
+      let item = this.users[index];
+      let usersAux = this.users;
+      
+      item.AUTHENABLED = !item.AUTHENABLED;
+      this.users = [];
+  
+      usersAux.forEach(user => {
+        if(user.IDUSUARIO == item.IDUSUARIO){
+          this.users.push(item);
+        }else{
+          this.users.push(user);
+        }
+      });
+  
+      this.dataSourceAuth = new MatTableDataSource(this.users);
+      let usrEnc = await this._encService.encriptar(item.IDUSUARIO);
+      let usrShort = await lastValueFrom(this._encService.shortEncrypt(usrEnc));
+      let idUser = localStorage.getItem('idusuario');
+      let idShort = await lastValueFrom(this._encService.shortEncrypt(idUser!));
+
+      await lastValueFrom(this._systemAdminService.setTwoStepsAuth({
+        id_user: idShort.response.encrypted,
+        usuario: usrShort.response.encrypted,
+        factor_doble: item.AUTHENABLED ? 'Si' : 'No',
+        linea: 1
+      }));
+    }catch(error: any){
+      let msg = '';
+      if(error.error == undefined){
+        msg = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        msg = 'Ocurrió un error inesperado.';
+      }else{
+        msg = error.error.msg;
+      }
+
+      this.openSnackBar(msg);
+    }
+  }
+
+  goBack(steps: number){
+    window.history.go(steps * -1);
+  }
+
+  editMinLength(action: number){
+    let minLengthStr = this.politicsForm.getRawValue().minLength;
+    let minLength = parseInt(minLengthStr!);
+    if(action == 0){
+      if(minLength > 8){
+        minLength--;
+        this.politicsForm.controls.minLength.setValue(`${minLength}`);
+      }
+    }else{
+      if(minLength < 30){
+        minLength++;
+        this.politicsForm.controls.minLength.setValue(`${minLength}`);
+      }
+    }
+  }
+
+  editMinUpper(action: number){
+    let minUpperStr = this.politicsForm.getRawValue().minUpper;
+    let minUpper = parseInt(minUpperStr!);
+    if(action == 0){
+      if(minUpper > 1){
+        minUpper--;
+        this.politicsForm.controls.minUpper.setValue(`${minUpper}`);
+      }
+    }else{
+      if(minUpper < 10){
+        minUpper++;
+        this.politicsForm.controls.minUpper.setValue(`${minUpper}`);
+      }
+    }
+  }
+
+  disableMinUpper(){
+    let isDisabled = this.politicsForm.controls.minUpper.disabled;
+    if(isDisabled){
+      this.politicsForm.controls.minUpper.enable();
+    }else{
+      this.politicsForm.controls.minUpper.disable();
+    }
+  }
+
+  editMinNumber(action: number){
+    let minNumberStr = this.politicsForm.getRawValue().minNumber;
+    let minNumber = parseInt(minNumberStr!);
+    if(action == 0){
+      if(minNumber > 1){
+        minNumber--;
+        this.politicsForm.controls.minNumber.setValue(`${minNumber}`);
+      }
+    }else{
+      if(minNumber < 10){
+        minNumber++;
+        this.politicsForm.controls.minNumber.setValue(`${minNumber}`);
+      }
+    }
+  }
+
+  disableMinNumber(){
+    let isDisabled = this.politicsForm.controls.minNumber.disabled;
+    if(isDisabled){
+      this.politicsForm.controls.minNumber.enable();
+    }else{
+      this.politicsForm.controls.minNumber.disable();
+    }
+  }
+
+  editMinCharacters(action: number){
+    let minCharactersStr = this.politicsForm.getRawValue().minCharacters;
+    let minCharacters = parseInt(minCharactersStr!);
+    if(action == 0){
+      if(minCharacters > 1){
+        minCharacters--;
+        this.politicsForm.controls.minCharacters.setValue(`${minCharacters}`);
+      }
+    }else{
+      if(minCharacters < 10){
+        minCharacters++;
+        this.politicsForm.controls.minCharacters.setValue(`${minCharacters}`);
+      }
+    }
+  }
+
+  disableMinCharacters(){
+    let isDisabled = this.politicsForm.controls.minCharacters.disabled;
+    if(isDisabled){
+      this.politicsForm.controls.minCharacters.enable();
+    }else{
+      this.politicsForm.controls.minCharacters.disable();
+    }
+  }
+
+  editDays(action: number){
+    let daysStr = this.sessionsForm.getRawValue().days;
+    let days = parseInt(daysStr!);
+    if(action == 0){
+      if(days > 0){
+        days--;
+        this.sessionsForm.controls.days.setValue(`${days}`);
+      }
+    }else{
+      if(days < 30){
+        days++;
+        this.sessionsForm.controls.days.setValue(`${days}`);
+      }
+    }
+  }
+
+  editHours(action: number){
+    let hoursStr = this.sessionsForm.getRawValue().hours;
+    let hours = parseInt(hoursStr!);
+    if(action == 0){
+      if(hours > 0){
+        hours--;
+        this.sessionsForm.controls.hours.setValue(`${hours}`);
+      }
+    }else{
+      if(hours < 23){
+        hours++;
+        this.sessionsForm.controls.hours.setValue(`${hours}`);
+      }
+    }
+  }
+
+  editMinutes(action: number){
+    let minutesStr = this.sessionsForm.getRawValue().minutes;
+    let minutes = parseInt(minutesStr!);
+    if(action == 0){
+      if(minutes > 0){
+        minutes--;
+        this.sessionsForm.controls.minutes.setValue(`${minutes}`);
+      }
+    }else{
+      if(minutes < 59){
+        minutes++;
+        this.sessionsForm.controls.minutes.setValue(`${minutes}`);
+      }
+    }
+  }
+
+  editSeconds(action: number){
+    let secondsStr = this.sessionsForm.getRawValue().seconds;
+    let seconds = parseInt(secondsStr!);
+    if(action == 0){
+      if(seconds > 0){
+        seconds--;
+        this.sessionsForm.controls.seconds.setValue(`${seconds}`);
+      }
+    }else{
+      if(seconds < 59){
+        seconds++;
+        this.sessionsForm.controls.seconds.setValue(`${seconds}`);
+      }
+    }
+  }
+
+  editNumber(action: number){
+    let numStr = this.sessionsNumberForm.getRawValue().number;
+    let num = parseInt(numStr!);
+    if(action == 0){
+      if(num > 1){
+        num--;
+        this.sessionsNumberForm.controls.number.setValue(`${num}`);
+      }
+    }else{
+      if(num < 5){
+        num++;
+        this.sessionsNumberForm.controls.number.setValue(`${num}`);
+      }
+    }
+  }
+}

+ 9 - 0
sistema-mantenimiento-front/src/app/interfaces/active-sessions-number.interface.ts

@@ -0,0 +1,9 @@
+export interface ActiveSessionsNumberResponse{
+    error: boolean;
+    msg: string;
+    response: ActiveSessionsNumber;
+}
+
+export interface ActiveSessionsNumber{
+    active_sessions_number: number;
+}

+ 19 - 0
sistema-mantenimiento-front/src/app/interfaces/password-format.interface.ts

@@ -0,0 +1,19 @@
+export interface PasswordFormatResponse{
+    error: boolean;
+    msg: string;
+    response: PasswordFormat;
+}
+
+export interface PasswordFormat{
+    password_format: PasswordProperties;
+}
+
+export interface PasswordProperties{
+    min_length: number;
+    upper_enabled: boolean;
+    min_upper: number;
+    number_enabled: boolean;
+    min_number: number;
+    chars_enabled: boolean;
+    min_chars: number;
+}

+ 16 - 0
sistema-mantenimiento-front/src/app/interfaces/sessions-duration.interface.ts

@@ -0,0 +1,16 @@
+export interface SessionsDurationsInterface{
+    error: boolean;
+    msg: string;
+    response: SessionsDuration;
+}
+
+export interface SessionsDuration{
+    sessions_duration: SessionsProperties;
+}
+
+export interface SessionsProperties{
+    days: number;
+    hours: number;
+    minutes: number;
+    seconds: number;
+}

+ 11 - 0
sistema-mantenimiento-front/src/app/interfaces/user-auths.interface.ts

@@ -0,0 +1,11 @@
+export interface UsersAuth{
+    error: boolean;
+    msg: string;
+    response: UserAuth[];
+}
+
+export interface UserAuth{
+    IDUSUARIO: string;
+    NOMBREUSUARIO: string;
+    AUTHENABLED: boolean;
+}

+ 32 - 0
sistema-mantenimiento-front/src/app/services/system-admin.service.ts

@@ -14,6 +14,22 @@ export class SystemAdminService {
     return this.getQuery(`get-advices/${id}/${line}`).pipe(map((data: any) => data));
   }
 
+  getTwoStepsAuth(id: string, line: number){
+    return this.getQuery(`get-two-steps-auths/${id}/${line}`).pipe(map((data: any) => data));
+  }
+
+  getPasswordFormat(id: string, line: number){
+    return this.getQuery(`get-password-format/${id}/${line}`).pipe(map((data: any) => data));
+  }
+
+  getSessionsDuration(id: string, line: number){
+    return this.getQuery(`get-sessions-duration/${id}/${line}`).pipe(map((data: any) => data));
+  }
+
+  getActiveSessionsNumber(id: string, line: number){
+    return this.getQuery(`get-active-sessions-number/${id}/${line}`).pipe(map((data: any) => data));
+  }
+
   uploadTempFile(body: any){
     return this.postQuery("upload-file", body).pipe(map((data: any) => data));
   }
@@ -22,6 +38,22 @@ export class SystemAdminService {
     return this.postQuery("delete-file", body).pipe(map((data: any) => data));
   }
 
+  setTwoStepsAuth(body: any){
+    return this.postQuery("set-two-steps-auth", body).pipe(map((data: any) => data));
+  }
+
+  savePasswordFormat(body: any){
+    return this.postQuery("save-password-format", body).pipe(map((data: any) => data));
+  }
+
+  saveSessionsDuration(body: any){
+    return this.postQuery("save-sessions-duration", body).pipe(map((data: any) => data));
+  }
+
+  saveActiveSessionsNumber(body: any){
+    return this.postQuery("save-active-sessions-number", body).pipe(map((data: any) => data));
+  }
+
   getQuery(query: string){
     const URL = `${apiTemp}${query}`;
     const token = `Bearer ${localStorage.getItem('token')!}`;