ngx-sp-auth 3.2.6 → 3.2.8
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
CHANGED
|
@@ -759,6 +759,34 @@ class ProjectUtilservice {
|
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
|
+
// Exibe a mensagem de erro de uma requisição HTTP em caso de lógica integrada OS
|
|
763
|
+
showHTTPErrorOS(error) {
|
|
764
|
+
if (error.error instanceof ErrorEvent) {
|
|
765
|
+
// Erro ocorreu no lado do cliente
|
|
766
|
+
this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
// Erro ocorreu no lado do servidor
|
|
770
|
+
let isUnauthorizedAccess = error.status === 401;
|
|
771
|
+
if (isUnauthorizedAccess) {
|
|
772
|
+
let isFromAplic = this.checkUrlAndMethodService.needsAuthRequest(error.url, "*", this._customEnvironmentService.needsAuthAplic);
|
|
773
|
+
if (isFromAplic) {
|
|
774
|
+
// Remove a autenticação do usuário.
|
|
775
|
+
this.authStorageService.isLoggedInSub.next(false);
|
|
776
|
+
this.authStorageService.urlRedirect = "/";
|
|
777
|
+
this.router.navigate(["/auth/login"]).then(e => {
|
|
778
|
+
this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
762
790
|
// Mostra uma mensagem de sessão expirada.
|
|
763
791
|
showExpiredAccess(navigationResult) {
|
|
764
792
|
if (navigationResult) {
|
|
@@ -2089,12 +2117,13 @@ class LoginOSComponent {
|
|
|
2089
2117
|
// #endregion PUBLIC
|
|
2090
2118
|
// #endregion ==========> PROPERTIES <==========
|
|
2091
2119
|
// #region ==========> INITIALIZATION <==========
|
|
2092
|
-
constructor(_authService,
|
|
2120
|
+
constructor(_authService, _projectUtilService, _route, _router, _storageService, _messageService) {
|
|
2093
2121
|
this._authService = _authService;
|
|
2094
|
-
this.
|
|
2122
|
+
this._projectUtilService = _projectUtilService;
|
|
2095
2123
|
this._route = _route;
|
|
2096
2124
|
this._router = _router;
|
|
2097
2125
|
this._storageService = _storageService;
|
|
2126
|
+
this._messageService = _messageService;
|
|
2098
2127
|
// #endregion PRIVATE
|
|
2099
2128
|
// #region PUBLIC
|
|
2100
2129
|
this.loginStatus = "loading";
|
|
@@ -2114,6 +2143,7 @@ class LoginOSComponent {
|
|
|
2114
2143
|
const currUsuario = this._storageService.user ?? undefined;
|
|
2115
2144
|
this._authService.getAuthentication(this._loginOSModel.dominio).subscribe({
|
|
2116
2145
|
next: () => {
|
|
2146
|
+
throw new Error("Erro de teste");
|
|
2117
2147
|
if (currDominio === this._loginOSModel.dominio && currUsuario === this._loginOSModel.usuario) {
|
|
2118
2148
|
status = "keep";
|
|
2119
2149
|
this.redirect();
|
|
@@ -2133,13 +2163,13 @@ class LoginOSComponent {
|
|
|
2133
2163
|
},
|
|
2134
2164
|
error: (error) => {
|
|
2135
2165
|
this.loginStatus = "error";
|
|
2136
|
-
this.
|
|
2166
|
+
this._projectUtilService.showHTTPErrorOS(error);
|
|
2137
2167
|
},
|
|
2138
2168
|
});
|
|
2139
2169
|
},
|
|
2140
2170
|
error: (error) => {
|
|
2141
2171
|
this.loginStatus = "error";
|
|
2142
|
-
this.
|
|
2172
|
+
this._projectUtilService.showHTTPErrorOS(error);
|
|
2143
2173
|
}
|
|
2144
2174
|
});
|
|
2145
2175
|
}
|
|
@@ -2166,8 +2196,11 @@ class LoginOSComponent {
|
|
|
2166
2196
|
getParams() {
|
|
2167
2197
|
const payloadString = this._route.snapshot.queryParamMap.get('payload');
|
|
2168
2198
|
if (!payloadString) {
|
|
2169
|
-
console.warn('Payload não encontrado na URL.');
|
|
2170
2199
|
this.loginStatus = "error";
|
|
2200
|
+
this._router.navigate(["/auth/login"]).then(e => {
|
|
2201
|
+
this._messageService.showAlertDanger('Payload não encontrado na URL.');
|
|
2202
|
+
});
|
|
2203
|
+
console.warn('Payload não encontrado na URL.');
|
|
2171
2204
|
throw new Error('Payload não encontrado na URL.');
|
|
2172
2205
|
}
|
|
2173
2206
|
try {
|
|
@@ -2185,6 +2218,10 @@ class LoginOSComponent {
|
|
|
2185
2218
|
};
|
|
2186
2219
|
}
|
|
2187
2220
|
catch (error) {
|
|
2221
|
+
this.loginStatus = "error";
|
|
2222
|
+
this._router.navigate(["/auth/login"]).then(e => {
|
|
2223
|
+
this._messageService.showAlertDanger('Erro ao fazer parse do payload.');
|
|
2224
|
+
});
|
|
2188
2225
|
console.error('Erro ao fazer parse do payload:', error);
|
|
2189
2226
|
throw error;
|
|
2190
2227
|
}
|
|
@@ -2193,7 +2230,7 @@ class LoginOSComponent {
|
|
|
2193
2230
|
ngOnDestroy() {
|
|
2194
2231
|
this._timerSubscription?.unsubscribe();
|
|
2195
2232
|
}
|
|
2196
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: LoginOSComponent, deps: [{ token: AuthService }, { token: ProjectUtilservice }, { token: i1$1.ActivatedRoute }, { token: i1$1.Router }, { token: AuthStorageService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2233
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: LoginOSComponent, deps: [{ token: AuthService }, { token: ProjectUtilservice }, { token: i1$1.ActivatedRoute }, { token: i1$1.Router }, { token: AuthStorageService }, { token: i3.MessageService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2197
2234
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: LoginOSComponent, isStandalone: true, selector: "login-os", ngImport: i0, template: `
|
|
2198
2235
|
<div class="d-flex flex-column justify-content-center align-items-center h-100 w-100 bg-light" >
|
|
2199
2236
|
|
|
@@ -2301,7 +2338,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
2301
2338
|
|
|
2302
2339
|
</div>
|
|
2303
2340
|
` }]
|
|
2304
|
-
}], ctorParameters: () => [{ type: AuthService }, { type: ProjectUtilservice }, { type: i1$1.ActivatedRoute }, { type: i1$1.Router }, { type: AuthStorageService }] });
|
|
2341
|
+
}], ctorParameters: () => [{ type: AuthService }, { type: ProjectUtilservice }, { type: i1$1.ActivatedRoute }, { type: i1$1.Router }, { type: AuthStorageService }, { type: i3.MessageService }] });
|
|
2305
2342
|
|
|
2306
2343
|
class SecondaryDropdownComponent {
|
|
2307
2344
|
constructor(_projectUtilservice) {
|