|
|
@@ -7,6 +7,8 @@ import { IAMInterface } from 'src/app/interfaces/iam/iam-interface';
|
|
|
import { ENCService } from '../enc/enc.service';
|
|
|
import { WebSocketService } from '../socket/web-socket.service';
|
|
|
import { ResponseData } from 'src/app/interfaces/response-data';
|
|
|
+import { LocalstorageService } from '../localstorage.service';
|
|
|
+import { AuthGuard } from 'src/app/auth/auth.guard';
|
|
|
|
|
|
@Injectable({
|
|
|
providedIn: 'root',
|
|
|
@@ -22,7 +24,9 @@ export class IAMService implements OnInit {
|
|
|
private _snackBar: MatSnackBar,
|
|
|
private router: Router,
|
|
|
private _encService: ENCService,
|
|
|
- private webSocketService: WebSocketService
|
|
|
+ private webSocketService: WebSocketService,
|
|
|
+ public setUserStorage: LocalstorageService,
|
|
|
+ private test: AuthGuard
|
|
|
) {
|
|
|
this.getIPAddress();
|
|
|
}
|
|
|
@@ -55,18 +59,15 @@ export class IAMService implements OnInit {
|
|
|
if (rfc_empresa == localStorage.getItem('RFCEMPRESA')) {
|
|
|
switch (status) {
|
|
|
case 'Activo':
|
|
|
+
|
|
|
+ console.log(data!.response);
|
|
|
+
|
|
|
this.current_user = JSON.stringify(data!.response);
|
|
|
this.jwt = data!.response.TOKEN;
|
|
|
-
|
|
|
- let jwt_local = localStorage.getItem('jwt');
|
|
|
- let TIMUSERENC_local = localStorage.getItem('TIMUSERENC');
|
|
|
-
|
|
|
+
|
|
|
localStorage.setItem('jwt', data!.response.TOKEN);
|
|
|
- localStorage.setItem(
|
|
|
- 'TIMUSERENC',
|
|
|
- JSON.stringify(data!.response)
|
|
|
- );
|
|
|
-
|
|
|
+ localStorage.setItem('TIMUSERENC',JSON.stringify(data?.response));
|
|
|
+ this.sendService(data?.response)
|
|
|
this.userType(perfil, solicitud_datos);
|
|
|
|
|
|
break;
|
|
|
@@ -104,6 +105,10 @@ export class IAMService implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ sendService(data:any){
|
|
|
+ this.setUserStorage.setUserStorage(JSON.stringify(data));
|
|
|
+
|
|
|
+ }
|
|
|
private snackAlert(mensaje: string) {
|
|
|
this._snackBar.open(mensaje, 'Cerrar', {
|
|
|
duration: 4000,
|
|
|
@@ -127,6 +132,10 @@ export class IAMService implements OnInit {
|
|
|
}
|
|
|
|
|
|
public logout(): void {
|
|
|
+
|
|
|
+ console.log(this.test.aux_test);
|
|
|
+
|
|
|
+ clearInterval(this.test.aux_test);
|
|
|
let rfc = localStorage.getItem('RFCEMPRESA');
|
|
|
if (rfc === null || rfc === undefined || rfc === '') {
|
|
|
localStorage.setItem('RFCEMPRESA', 'ITTEC');
|
|
|
@@ -139,7 +148,8 @@ export class IAMService implements OnInit {
|
|
|
}
|
|
|
|
|
|
private userType(perfil: string, solicitud_datos: string) {
|
|
|
- if (perfil == 'Administrador') {
|
|
|
+
|
|
|
+ if (perfil == "1") {
|
|
|
if (solicitud_datos == '') {
|
|
|
this.router.navigate(['/admin/mesmpr']);
|
|
|
} else {
|