ngx-sp-auth 3.2.7 → 3.2.9
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
|
@@ -104,13 +104,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
104
104
|
}]
|
|
105
105
|
}] });
|
|
106
106
|
|
|
107
|
-
var InfraInAuthTypeId;
|
|
108
|
-
(function (InfraInAuthTypeId) {
|
|
109
|
-
InfraInAuthTypeId[InfraInAuthTypeId["Local"] = 1] = "Local";
|
|
110
|
-
InfraInAuthTypeId[InfraInAuthTypeId["Azure"] = 2] = "Azure";
|
|
111
|
-
InfraInAuthTypeId[InfraInAuthTypeId["LDAP"] = 3] = "LDAP";
|
|
112
|
-
})(InfraInAuthTypeId || (InfraInAuthTypeId = {}));
|
|
113
|
-
|
|
114
107
|
var InfraIn2FaTypeId;
|
|
115
108
|
(function (InfraIn2FaTypeId) {
|
|
116
109
|
InfraIn2FaTypeId[InfraIn2FaTypeId["Email"] = 1] = "Email";
|
|
@@ -118,6 +111,13 @@ var InfraIn2FaTypeId;
|
|
|
118
111
|
InfraIn2FaTypeId[InfraIn2FaTypeId["Microsoft"] = 3] = "Microsoft";
|
|
119
112
|
})(InfraIn2FaTypeId || (InfraIn2FaTypeId = {}));
|
|
120
113
|
|
|
114
|
+
var InfraInAuthTypeId;
|
|
115
|
+
(function (InfraInAuthTypeId) {
|
|
116
|
+
InfraInAuthTypeId[InfraInAuthTypeId["Local"] = 1] = "Local";
|
|
117
|
+
InfraInAuthTypeId[InfraInAuthTypeId["Azure"] = 2] = "Azure";
|
|
118
|
+
InfraInAuthTypeId[InfraInAuthTypeId["LDAP"] = 3] = "LDAP";
|
|
119
|
+
})(InfraInAuthTypeId || (InfraInAuthTypeId = {}));
|
|
120
|
+
|
|
121
121
|
// Token para o LibCustomEnvironmentService
|
|
122
122
|
const LIB_CUSTOM_ENVIRONMENT_SERVICE = new InjectionToken('LibCustomEnvironmentService');
|
|
123
123
|
// Token para o LibCustomStorageService
|
|
@@ -759,6 +759,40 @@ 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.router.navigate(["/auth/login"]).then(e => {
|
|
767
|
+
this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
else {
|
|
771
|
+
// Erro ocorreu no lado do servidor
|
|
772
|
+
let isUnauthorizedAccess = error.status === 401;
|
|
773
|
+
if (isUnauthorizedAccess) {
|
|
774
|
+
let isFromAplic = this.checkUrlAndMethodService.needsAuthRequest(error.url, "*", this._customEnvironmentService.needsAuthAplic);
|
|
775
|
+
if (isFromAplic) {
|
|
776
|
+
// Remove a autenticação do usuário.
|
|
777
|
+
this.authStorageService.isLoggedInSub.next(false);
|
|
778
|
+
this.authStorageService.urlRedirect = "/";
|
|
779
|
+
this.router.navigate(["/auth/login"]).then(e => {
|
|
780
|
+
this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
this.router.navigate(["/auth/login"]).then(e => {
|
|
785
|
+
this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
this.router.navigate(["/auth/login"]).then(e => {
|
|
791
|
+
this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
762
796
|
// Mostra uma mensagem de sessão expirada.
|
|
763
797
|
showExpiredAccess(navigationResult) {
|
|
764
798
|
if (navigationResult) {
|
|
@@ -1102,6 +1136,7 @@ class AuthService {
|
|
|
1102
1136
|
}
|
|
1103
1137
|
}));
|
|
1104
1138
|
}
|
|
1139
|
+
/** Realiza o logout do sistema, removendo tokens do localStorage e limpando cache */
|
|
1105
1140
|
logout() {
|
|
1106
1141
|
this._authStorageService.logout();
|
|
1107
1142
|
localStorage.removeItem('configsServerUser');
|
|
@@ -2102,6 +2137,7 @@ class LoginOSComponent {
|
|
|
2102
2137
|
this.timer = 3;
|
|
2103
2138
|
}
|
|
2104
2139
|
ngOnInit() {
|
|
2140
|
+
this._storageService.logout();
|
|
2105
2141
|
this.getParams();
|
|
2106
2142
|
this.logOn();
|
|
2107
2143
|
}
|
|
@@ -2134,13 +2170,13 @@ class LoginOSComponent {
|
|
|
2134
2170
|
},
|
|
2135
2171
|
error: (error) => {
|
|
2136
2172
|
this.loginStatus = "error";
|
|
2137
|
-
this._projectUtilService.
|
|
2173
|
+
this._projectUtilService.showHTTPErrorOS(error);
|
|
2138
2174
|
},
|
|
2139
2175
|
});
|
|
2140
2176
|
},
|
|
2141
2177
|
error: (error) => {
|
|
2142
2178
|
this.loginStatus = "error";
|
|
2143
|
-
this._projectUtilService.
|
|
2179
|
+
this._projectUtilService.showHTTPErrorOS(error);
|
|
2144
2180
|
}
|
|
2145
2181
|
});
|
|
2146
2182
|
}
|
|
@@ -2167,8 +2203,10 @@ class LoginOSComponent {
|
|
|
2167
2203
|
getParams() {
|
|
2168
2204
|
const payloadString = this._route.snapshot.queryParamMap.get('payload');
|
|
2169
2205
|
if (!payloadString) {
|
|
2170
|
-
this._messageService.showAlertDanger('Payload não encontrado na URL.');
|
|
2171
2206
|
this.loginStatus = "error";
|
|
2207
|
+
this._router.navigate(["/auth/login"]).then(e => {
|
|
2208
|
+
this._messageService.showAlertDanger('Payload não encontrado na URL.');
|
|
2209
|
+
});
|
|
2172
2210
|
console.warn('Payload não encontrado na URL.');
|
|
2173
2211
|
throw new Error('Payload não encontrado na URL.');
|
|
2174
2212
|
}
|
|
@@ -2187,8 +2225,10 @@ class LoginOSComponent {
|
|
|
2187
2225
|
};
|
|
2188
2226
|
}
|
|
2189
2227
|
catch (error) {
|
|
2190
|
-
this._messageService.showAlertDanger('Erro ao fazer parse do payload.');
|
|
2191
2228
|
this.loginStatus = "error";
|
|
2229
|
+
this._router.navigate(["/auth/login"]).then(e => {
|
|
2230
|
+
this._messageService.showAlertDanger('Erro ao fazer parse do payload.');
|
|
2231
|
+
});
|
|
2192
2232
|
console.error('Erro ao fazer parse do payload:', error);
|
|
2193
2233
|
throw error;
|
|
2194
2234
|
}
|