ngx-sp-auth 4.22.14 → 4.22.17
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
|
@@ -897,7 +897,6 @@ class AuthStorageService {
|
|
|
897
897
|
const headers = this._HTTP_HEADERS;
|
|
898
898
|
return this._httpClient.get(url, { 'headers': headers, withCredentials: true })
|
|
899
899
|
.pipe(take(1), tap(res => {
|
|
900
|
-
console.log(res);
|
|
901
900
|
if (res.Error)
|
|
902
901
|
this.isLoggedInSub.next(false);
|
|
903
902
|
else
|
|
@@ -949,25 +948,18 @@ class AuthStorageService {
|
|
|
949
948
|
async logout() {
|
|
950
949
|
// Consumo de endpoint de logout
|
|
951
950
|
const url = `${this._LOGOUT_BASE_URL}`;
|
|
952
|
-
|
|
953
|
-
await firstValueFrom(this._httpClient.post(url, null, { 'headers': this._HTTP_HEADERS, withCredentials: true })).then((res) => {
|
|
954
|
-
console.log('2. res:', res);
|
|
955
|
-
})
|
|
951
|
+
await firstValueFrom(this._httpClient.post(url, null, { 'headers': this._HTTP_HEADERS, withCredentials: true })).then((res) => { })
|
|
956
952
|
.catch((err) => {
|
|
957
|
-
console.
|
|
953
|
+
console.error(err);
|
|
958
954
|
})
|
|
959
955
|
.then(() => {
|
|
960
956
|
// Independente de sucesso ou erro, realiza a limpeza do localStorage após o endpoint ser chamado
|
|
961
|
-
console.log('3. Removendo variáveis de configuração do usuário e senha do localStorage');
|
|
962
957
|
localStorage.removeItem('configServerUser');
|
|
963
958
|
localStorage.removeItem('configServerPassword');
|
|
964
|
-
console.log('4. Chamando método onLogout() para limpar variáveis de autenticação e redirecionar para a tela de login');
|
|
965
959
|
this.onLogout();
|
|
966
960
|
// Método com customizações para inicializações do Logout
|
|
967
|
-
console.log('5. Chamando método authLogout() do serviço de customização para realizar ações de logout específicas');
|
|
968
961
|
this._customLoginService.authLogout();
|
|
969
962
|
});
|
|
970
|
-
console.log('6. Navegando para rota de login');
|
|
971
963
|
return this._router.navigate(["/auth/login"]);
|
|
972
964
|
}
|
|
973
965
|
getNewTokenBack() {
|
|
@@ -1026,7 +1018,6 @@ class AuthStorageService {
|
|
|
1026
1018
|
// }
|
|
1027
1019
|
// }
|
|
1028
1020
|
onLogout() {
|
|
1029
|
-
console.log('4.1. Iniciando onLogout() para limpar variáveis de autenticação e redirecionar para a tela de login');
|
|
1030
1021
|
this.__isCheckingAuth = false;
|
|
1031
1022
|
this.__authenticationCheck$ = null;
|
|
1032
1023
|
this.isLoggedInSub.next(false);
|
|
@@ -1049,7 +1040,6 @@ class AuthStorageService {
|
|
|
1049
1040
|
this.__is2FaEnabled = false;
|
|
1050
1041
|
this.__azureTenantId = "";
|
|
1051
1042
|
this.__azureClientId = "";
|
|
1052
|
-
console.log('4.2. __localKey:', this.__local_key);
|
|
1053
1043
|
localStorage.removeItem(this.__local_key);
|
|
1054
1044
|
// Limpa o armazenamento local do navegador que contém os filtros de um produto específico
|
|
1055
1045
|
// Fecha a conexão local (se houver) antes de excluir a database para evitar o callback 'blocking'
|
|
@@ -4698,7 +4688,6 @@ class LoginGuard {
|
|
|
4698
4688
|
* @returns
|
|
4699
4689
|
*/
|
|
4700
4690
|
canLoad(_route, _segments) {
|
|
4701
|
-
console.log('route', _route);
|
|
4702
4691
|
return this.authStorageService.checkAuthentication()
|
|
4703
4692
|
.pipe(map(() => {
|
|
4704
4693
|
if ((_route.path === "auth/login" && this.authStorageService.isLoggedInSub.value && !this.authStorageService.isExternalLogin)) {
|
|
@@ -4760,8 +4749,6 @@ class AuthAplicInterceptor {
|
|
|
4760
4749
|
// Verifica se o Token precisa ser renovado
|
|
4761
4750
|
// await this._authStorage.renewToken();
|
|
4762
4751
|
// Adiciona as autenticações necessárias ao servidor.
|
|
4763
|
-
// Daqui alguns dias este trecho será removido e os tokens serão enviados exclusivamente pelos Cookies, mas por enquanto, para manter compatibilidade com o que já existe, o token será enviado no header
|
|
4764
|
-
// let headers: HttpHeaders = req.headers.set('Authorization', `Bearer ${this._authStorage.authToken}`);
|
|
4765
4752
|
changedReq = req.clone({ headers: req.headers, withCredentials: true });
|
|
4766
4753
|
}
|
|
4767
4754
|
// return await lastValueFrom(next.handle(changedReq));
|
|
@@ -4796,18 +4783,8 @@ class AuthInfraInterceptor {
|
|
|
4796
4783
|
intercept(req, next) {
|
|
4797
4784
|
let changedReq = req;
|
|
4798
4785
|
if (this._authCheckService.needsAuthRequest(req.url, req.method, this._customEnvironmentService.needsAuthInfra)) {
|
|
4799
|
-
// Instanciado inicialmente com os headers da requisição original, para não perder nenhum header que já tenha sido adicionado
|
|
4800
|
-
let headers = req.headers;
|
|
4801
4786
|
// Adiciona as autenticações necessárias ao servidor. Autenticação básica.
|
|
4802
|
-
|
|
4803
|
-
if (localStorage.getItem('configServerUser') && localStorage.getItem('configServerPassword')) {
|
|
4804
|
-
headers = req.headers.set("Authorization", `Basic ${btoa(`${localStorage.getItem('configServerUser')}:${localStorage.getItem('configServerPassword')}`)}
|
|
4805
|
-
`);
|
|
4806
|
-
}
|
|
4807
|
-
changedReq = req.clone({
|
|
4808
|
-
headers: req.headers,
|
|
4809
|
-
withCredentials: true // Parâmetro necessário para utilização dos Cookies HttpOnly
|
|
4810
|
-
});
|
|
4787
|
+
changedReq = req.clone({ headers: req.headers, withCredentials: true });
|
|
4811
4788
|
}
|
|
4812
4789
|
// return next.handle(changedReq);
|
|
4813
4790
|
// Exemplo de leitura de resposta via interceptor abaixo:
|
|
@@ -4815,12 +4792,12 @@ class AuthInfraInterceptor {
|
|
|
4815
4792
|
// INTERCEPTAR RESPOSTA
|
|
4816
4793
|
.pipe(tap(event => {
|
|
4817
4794
|
if (event instanceof HttpResponse) {
|
|
4818
|
-
console.log("Resposta HTTP interceptada:", event);
|
|
4795
|
+
// console.log("Resposta HTTP interceptada:", event);
|
|
4819
4796
|
}
|
|
4820
4797
|
}),
|
|
4821
4798
|
// INTERCEPTAR ERRO
|
|
4822
4799
|
catchError(error => {
|
|
4823
|
-
console.error("Erro HTTP interceptado:", error);
|
|
4800
|
+
// console.error("Erro HTTP interceptado:", error);
|
|
4824
4801
|
return throwError(() => error);
|
|
4825
4802
|
}));
|
|
4826
4803
|
}
|