@osovitny/anatoly 3.19.5 → 3.19.6
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.
|
@@ -2003,21 +2003,26 @@ class AuthService extends ApiServiceBase {
|
|
|
2003
2003
|
}));
|
|
2004
2004
|
}
|
|
2005
2005
|
//2. if isUserAuthenticated
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
return response
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2006
|
+
try {
|
|
2007
|
+
let activeAccount = this.getActiveAccount();
|
|
2008
|
+
if (activeAccount) {
|
|
2009
|
+
let silentRequest = {
|
|
2010
|
+
scopes: MSALUtils.getApiScopes(),
|
|
2011
|
+
account: activeAccount
|
|
2012
|
+
};
|
|
2013
|
+
return this.msalService.acquireTokenSilent(silentRequest).pipe(map$1(response => {
|
|
2014
|
+
return response.accessToken;
|
|
2015
|
+
}), catchError(error => {
|
|
2016
|
+
console.log("Silent token acquisition fails.");
|
|
2017
|
+
if (error instanceof InteractionRequiredAuthError) {
|
|
2018
|
+
return this.acquireToken();
|
|
2019
|
+
}
|
|
2020
|
+
return of(null);
|
|
2021
|
+
}));
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
catch (error) {
|
|
2025
|
+
console.error("An error occurred: ", error);
|
|
2021
2026
|
}
|
|
2022
2027
|
return of(null);
|
|
2023
2028
|
}
|
|
@@ -2475,8 +2480,8 @@ class AnatolyHttpInterceptor {
|
|
|
2475
2480
|
}
|
|
2476
2481
|
},
|
|
2477
2482
|
error: (err) => {
|
|
2478
|
-
this.onRequestEnd(loadingRequired);
|
|
2479
2483
|
this.logger.error(err);
|
|
2484
|
+
this.onRequestEnd(loadingRequired);
|
|
2480
2485
|
}
|
|
2481
2486
|
}));
|
|
2482
2487
|
}
|
|
@@ -2550,17 +2555,23 @@ class AnatolyHttpInterceptor {
|
|
|
2550
2555
|
req = req.clone({ url: newUrl });
|
|
2551
2556
|
req = req.clone({ headers: req.headers.set('Accept', 'application/json') });
|
|
2552
2557
|
req = req.clone({ headers: req.headers.set('Accept', 'application/text') });
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2558
|
+
try {
|
|
2559
|
+
this.onRequestStart(loadingRequired);
|
|
2560
|
+
if (authorizationTokenRequired) {
|
|
2561
|
+
return this.authService.getAccessToken().pipe(mergeMap((token) => {
|
|
2562
|
+
if (token) {
|
|
2563
|
+
req = req.clone({ headers: req.headers.set('Authorization', 'Bearer ' + token) });
|
|
2564
|
+
}
|
|
2565
|
+
return this.handleHttpRequest(req, next, loadingRequired);
|
|
2566
|
+
}));
|
|
2567
|
+
}
|
|
2568
|
+
else {
|
|
2559
2569
|
return this.handleHttpRequest(req, next, loadingRequired);
|
|
2560
|
-
}
|
|
2570
|
+
}
|
|
2561
2571
|
}
|
|
2562
|
-
|
|
2563
|
-
|
|
2572
|
+
catch (err) {
|
|
2573
|
+
this.logger.error("An error occurred: " + err);
|
|
2574
|
+
this.onRequestEnd(loadingRequired);
|
|
2564
2575
|
}
|
|
2565
2576
|
}
|
|
2566
2577
|
//Events
|