ngx-sp-auth 4.23.14 → 4.23.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2318,6 +2318,40 @@ class LoginOSModel {
2318
2318
  }
2319
2319
  }
2320
2320
 
2321
+ class LoginOSUtilsService {
2322
+ // #endregion PRIVATE
2323
+ // #endregion ==========> PROPERTIES <==========
2324
+ constructor() {
2325
+ // #region ==========> PROPERTIES <==========
2326
+ // #region PRIVATE
2327
+ this._http = inject(HttpClient);
2328
+ this._customEnvironment = inject(LibCustomEnvironmentService);
2329
+ this._BASE_URL = `${this._customEnvironment.SpInfra2ErpWS}`; // SpInfra2ErpWS
2330
+ this._HTTP_HEADERS = new HttpHeaders().set('Content-Type', 'application/json');
2331
+ this._BASE_URL = !this._customEnvironment.production ? this._BASE_URL : `${this._customEnvironment.SpInfra2ErpWS}`;
2332
+ }
2333
+ // #region ==========> API <==========
2334
+ // #region GET
2335
+ getEstabelecimentoSession(estabID) {
2336
+ const params = new HttpParams().set('id', estabID);
2337
+ const url = `${this._BASE_URL}/InfraEstabelecimento/GetEstabelecimentoSession`;
2338
+ return this._http.get(url, { 'params': params, 'headers': this._HTTP_HEADERS })
2339
+ .pipe(take(1), tap(response => {
2340
+ if (response.Error) {
2341
+ throw Error(response.ErrorMessage);
2342
+ }
2343
+ }));
2344
+ }
2345
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LoginOSUtilsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2346
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LoginOSUtilsService, providedIn: 'root' }); }
2347
+ }
2348
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LoginOSUtilsService, decorators: [{
2349
+ type: Injectable,
2350
+ args: [{
2351
+ providedIn: 'root'
2352
+ }]
2353
+ }], ctorParameters: () => [] });
2354
+
2321
2355
  class LoginOSComponent {
2322
2356
  // #endregion PUBLIC
2323
2357
  // #endregion ==========> PROPERTIES <==========
@@ -2329,6 +2363,9 @@ class LoginOSComponent {
2329
2363
  this._router = _router;
2330
2364
  this._storageService = _storageService;
2331
2365
  this._messageService = _messageService;
2366
+ // #region ==========> PROPERTIES <==========
2367
+ // #region PRIVATE
2368
+ this._loginOSUtils = inject(LoginOSUtilsService);
2332
2369
  // #endregion PRIVATE
2333
2370
  // #region PUBLIC
2334
2371
  this.loginStatus = "loading";
@@ -2355,9 +2392,24 @@ class LoginOSComponent {
2355
2392
  this._authService.getAuthentication(this._loginOSModel.dominio).subscribe({
2356
2393
  next: () => {
2357
2394
  if (currDominio === this._loginOSModel.dominio && currUsuario === this._loginOSModel.usuario) {
2358
- status = "keep";
2359
- this.redirect();
2360
- return;
2395
+ // VALIDAR ÚLTIMO ESTAB LOGADO
2396
+ this._loginOSUtils.getEstabelecimentoSession('').subscribe({
2397
+ next: res => {
2398
+ // Atualiza os dados do estabelecimento na sessão
2399
+ this._storageService.infraEstabId = res.InfraEstabId;
2400
+ this._storageService.infraEstabNome = res.InfraEstabNome;
2401
+ this._storageService.infraEmpresaId = res.InfraEmpresaId;
2402
+ this._storageService.infraEmpresaNome = res.InfraEmpresaNome;
2403
+ // Após, redireciona para a URL de destino
2404
+ status = "keep";
2405
+ this.redirect();
2406
+ return;
2407
+ },
2408
+ error: error => {
2409
+ this.loginStatus = "error";
2410
+ this._authUtilService.showHTTPErrorOS(error);
2411
+ }
2412
+ });
2361
2413
  }
2362
2414
  status = (!currDominio || !currUsuario) ? "none" : "updated";
2363
2415
  this._authService.loginOS(this._parmsLogin, this._loginOSModel.serialV6).subscribe({
@@ -3663,6 +3715,8 @@ class MenuLateralComponent {
3663
3715
  this._menuServices.getEstabelecimentoSession(estabID).subscribe({
3664
3716
  next: response => {
3665
3717
  this.nomeEstabelecimento = response.InfraEstabNome;
3718
+ this._authStorageService.infraEstabId = response.InfraEstabId;
3719
+ this._authStorageService.infraEstabNome = response.InfraEstabNome;
3666
3720
  this._authStorageService.infraEmpresaId = response.InfraEmpresaId;
3667
3721
  this._authStorageService.infraEmpresaNome = response.InfraEmpresaNome;
3668
3722
  },