@amedia/user 0.14.11 → 0.14.13
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/package.json
CHANGED
|
@@ -113,7 +113,7 @@ describe('attemptAutoLoginJob', () => {
|
|
|
113
113
|
describe('when a strategy triggers auto login', () => {
|
|
114
114
|
beforeEach(async () => {
|
|
115
115
|
shouldPerformAutoLogin = true;
|
|
116
|
-
|
|
116
|
+
attemptAutoLoginJob();
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
itShouldCallThirdPartyCookieStrategy();
|
|
@@ -235,7 +235,7 @@ describe('attemptPaywallAutoLogin', () => {
|
|
|
235
235
|
describe('when already tried cookie is not found', () => {
|
|
236
236
|
beforeEach(async () => {
|
|
237
237
|
getCookieSpy.and.returnValue(undefined);
|
|
238
|
-
|
|
238
|
+
attemptPaywallAutoLogin();
|
|
239
239
|
});
|
|
240
240
|
itShouldNavigateToAutoLogin('paywall');
|
|
241
241
|
});
|
|
@@ -254,7 +254,7 @@ describe('attemptPaywallAutoLogin', () => {
|
|
|
254
254
|
getCookieSpy.and.returnValue(
|
|
255
255
|
Date.now() - AUTOLOGIN_COOKIE_TTL - 1000
|
|
256
256
|
);
|
|
257
|
-
|
|
257
|
+
attemptPaywallAutoLogin();
|
|
258
258
|
});
|
|
259
259
|
itShouldNavigateToAutoLogin('paywall');
|
|
260
260
|
});
|
package/src/autologin/index.ts
CHANGED
|
@@ -70,7 +70,7 @@ const attemptAutologin = async (strategies: Strategies) => {
|
|
|
70
70
|
.then((shouldPerformAutoLogin) => {
|
|
71
71
|
if (shouldPerformAutoLogin) {
|
|
72
72
|
if (hasAlreadyAttemptedAutoLogin()) {
|
|
73
|
-
return false;
|
|
73
|
+
return Promise.resolve(false);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// Try to get newspaper cookie
|
|
@@ -78,12 +78,20 @@ const attemptAutologin = async (strategies: Strategies) => {
|
|
|
78
78
|
url.searchParams.set('context', `auto_login_${strategy.name}`);
|
|
79
79
|
url.searchParams.set('requestedUrl', getCurrentUrl());
|
|
80
80
|
navigateTo(url.href);
|
|
81
|
-
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Don't resolve autologin promise when navigating away.
|
|
84
|
+
* This will cause waiting code to execute as if the user did/did not have access
|
|
85
|
+
* and will in turn cause flickering and unnecessary (and often aborted) request to
|
|
86
|
+
* various backends.
|
|
87
|
+
*/
|
|
88
|
+
return new Promise(() => {});
|
|
82
89
|
}
|
|
83
|
-
return true;
|
|
90
|
+
return Promise.resolve(true);
|
|
84
91
|
});
|
|
85
92
|
|
|
86
|
-
|
|
93
|
+
// eslint-disable-next-line no-await-in-loop
|
|
94
|
+
if (!(await shouldTryMoreStrategies)) {
|
|
87
95
|
return;
|
|
88
96
|
}
|
|
89
97
|
}
|