mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
1 line
27 KiB
JSON
1 line
27 KiB
JSON
|
|
{"ast":null,"code":"import _asyncToGenerator from \"C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { __decorate } from \"tslib\";\nimport { Injectable, ErrorHandler } from '@angular/core';\nimport { StorageService } from './storage.service';\nimport { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';\nimport { environment } from 'src/environments/environment';\nimport { BehaviorSubject } from 'rxjs';\nimport { AlertController } from '@ionic/angular';\nimport { SessionStore } from '../store/session.service';\nimport { AESEncrypt } from '../services/aesencrypt.service';\nimport { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';\nimport { Router } from '@angular/router';\nimport { NfService } from 'src/app/services/chat/nf.service';\nimport { ProcessesService } from 'src/app/services/processes.service';\nimport { AttachmentsService } from 'src/app/services/attachments.service';\nimport { Storage } from '@ionic/storage';\nimport { InitialsService } from './functions/initials.service';\nimport { PermissionService } from './permission.service';\nimport { ChatSystemService } from 'src/app/services/chat/chat-system.service';\nimport { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\nimport { captureException } from '@sentry/angular';\nlet AuthService = class AuthService {\n constructor(http, storageService, alertController, aesencrypt, RochetChatConnectorService, router, NfService, processesService, AttachmentsService, storage, initialsService, p, ChatSystemService, httpErroHandle, errorHandler) {\n this.http = http;\n this.storageService = storageService;\n this.alertController = alertController;\n this.aesencrypt = aesencrypt;\n this.RochetChatConnectorService = RochetChatConnectorService;\n this.router = router;\n this.NfService = NfService;\n this.processesService = processesService;\n this.AttachmentsService = AttachmentsService;\n this.storage = storage;\n this.initialsService = initialsService;\n this.p = p;\n this.ChatSystemService = ChatSystemService;\n this.httpErroHandle = httpErroHandle;\n this.errorHandler = errorHandler;\n this.userData$ = new BehaviorSubject('');\n this.userId$ = new BehaviorSubject('');\n this.headers = new HttpHeaders();\n this.isWsAuthenticated = false;\n this.tabIsActive = true;\n if (SessionStore.exist) {\n if (this.p.userPermission(this.p.permissionList.Chat.access) == true) {\n this.loginToChatWs();\n }\n }\n window.addEventListener('focus', event => {\n if (!this.tabIsActive) {\n this.tabIsActive = true;\n const data = SessionStore.getDataFromLocalStorage();\n if (!data?.user?.Authorization && SessionStore?.user?.Authorization) {\n window.location.reload();\n }\n }\n });\n window.addEventListener('blur', event => {\n this.tabIsActive = false;\n });\n }\n login(user, {\n saveSession = true\n }) {\n var _this = this;\n return _asyncToGenerator(function* () {\n user.BasicAuthKey = 'Basic ' + btoa(user.username + ':' + _this.aesencrypt.encrypt(user.password, user.username));\n // Basic peter.maquiran@equilibrium.co.ao:senha123456\n // console.log(user.BasicAuthKey)\n _this.headers = _this.headers.set('Authorization', user.BasicAuthKey);\n _this.opts = {\n headers: _this.headers\n };\n let response;\n try {\n response = yield _this.http.post(environment.apiURL + \"UserAuthentication/Login\", '', _this.opts).toPromise();\n if (saveSession) {\n _this.SetSession(response, user);\n }\n } catch (error) {\n /* throw(`Login ${error} `); */\n _this.errorHandler.handleError(error);\n _this.httpErroHandle.httpStatusHandle(error);\n captureException(error);\n } finally {\n return response;\n }\n })();\n }\n // async UpdateLogin() {}\n SetSession(response, u
|