ngx-sp-auth 4.23.13 → 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.
- package/fesm2022/ngx-sp-auth.mjs +66 -6
- package/fesm2022/ngx-sp-auth.mjs.map +1 -1
- package/lib/components/login-os/login-os-utils.service.d.ts +13 -0
- package/lib/components/login-os/login-os.component.d.ts +1 -0
- package/lib/components/menu-lateral/model/ret-estabelecimento-session.d.ts +1 -0
- package/package.json +1 -1
package/fesm2022/ngx-sp-auth.mjs
CHANGED
|
@@ -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,13 +2363,21 @@ 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";
|
|
2335
2372
|
this.timer = 3;
|
|
2336
2373
|
}
|
|
2337
2374
|
ngOnInit() {
|
|
2338
|
-
this._storageService.
|
|
2375
|
+
this._storageService.isLoggedInSub.subscribe(async (isLoggedIn) => {
|
|
2376
|
+
if (isLoggedIn) {
|
|
2377
|
+
// Comentado até encontrar uma maneira melhor de realizar o logout, pois o logout atual está causando problemas de redirecionamento e perda de sessão.
|
|
2378
|
+
// await this._storageService.logout();
|
|
2379
|
+
}
|
|
2380
|
+
});
|
|
2339
2381
|
this.getParams();
|
|
2340
2382
|
this.logOn();
|
|
2341
2383
|
}
|
|
@@ -2350,9 +2392,24 @@ class LoginOSComponent {
|
|
|
2350
2392
|
this._authService.getAuthentication(this._loginOSModel.dominio).subscribe({
|
|
2351
2393
|
next: () => {
|
|
2352
2394
|
if (currDominio === this._loginOSModel.dominio && currUsuario === this._loginOSModel.usuario) {
|
|
2353
|
-
|
|
2354
|
-
this.
|
|
2355
|
-
|
|
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
|
+
});
|
|
2356
2413
|
}
|
|
2357
2414
|
status = (!currDominio || !currUsuario) ? "none" : "updated";
|
|
2358
2415
|
this._authService.loginOS(this._parmsLogin, this._loginOSModel.serialV6).subscribe({
|
|
@@ -3658,6 +3715,8 @@ class MenuLateralComponent {
|
|
|
3658
3715
|
this._menuServices.getEstabelecimentoSession(estabID).subscribe({
|
|
3659
3716
|
next: response => {
|
|
3660
3717
|
this.nomeEstabelecimento = response.InfraEstabNome;
|
|
3718
|
+
this._authStorageService.infraEstabId = response.InfraEstabId;
|
|
3719
|
+
this._authStorageService.infraEstabNome = response.InfraEstabNome;
|
|
3661
3720
|
this._authStorageService.infraEmpresaId = response.InfraEmpresaId;
|
|
3662
3721
|
this._authStorageService.infraEmpresaNome = response.InfraEmpresaNome;
|
|
3663
3722
|
},
|
|
@@ -4538,8 +4597,9 @@ class AuthGuard {
|
|
|
4538
4597
|
IsUserAuth(targetUrl = this._router.url) {
|
|
4539
4598
|
return this._authStorage.checkAuthentication()
|
|
4540
4599
|
.pipe(map$1(({ error, isLoggedIn }) => {
|
|
4541
|
-
|
|
4542
|
-
|
|
4600
|
+
const targetPath = targetUrl.split(/[?#]/, 1)[0].replace(/\/+$/, '').toLowerCase();
|
|
4601
|
+
const isPublicRoute = ['/auth/login', '/senha-config', '/login-os', '/error-404'].includes(targetPath);
|
|
4602
|
+
if ((!isLoggedIn || this._authStorage.isExternalLogin) && !isPublicRoute) {
|
|
4543
4603
|
if (error.trim() && (targetPath !== '/auth/login' && targetPath !== '')) {
|
|
4544
4604
|
this._router.events.pipe(filter$1((event) => event instanceof NavigationEnd), filter$1(event => event.urlAfterRedirects.split(/[?#]/, 1)[0] === '/auth/login'), take$1(1))
|
|
4545
4605
|
.subscribe(() => this._message.showAlertWarning(error));
|