@amedia/user 0.14.11 → 0.14.12
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 +1 -1
- package/src/autologin/index.spec.ts +10 -10
- package/src/autologin/index.ts +8 -1
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();
|
|
@@ -121,7 +121,7 @@ describe('attemptAutoLoginJob', () => {
|
|
|
121
121
|
});
|
|
122
122
|
describe('when no strategy triggers auto login', () => {
|
|
123
123
|
beforeEach(async () => {
|
|
124
|
-
|
|
124
|
+
attemptAutoLoginJob();
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
itShouldCallThirdPartyCookieStrategy();
|
|
@@ -132,7 +132,7 @@ describe('attemptAutoLoginJob', () => {
|
|
|
132
132
|
describe('when tried within the last minute', () => {
|
|
133
133
|
beforeEach(async () => {
|
|
134
134
|
getCookieSpy.and.returnValue(Date.now());
|
|
135
|
-
|
|
135
|
+
attemptAutoLoginJob();
|
|
136
136
|
});
|
|
137
137
|
itShouldCallThirdPartyCookieStrategy();
|
|
138
138
|
itShouldNotNavigateAway();
|
|
@@ -143,7 +143,7 @@ describe('attemptAutoLoginJob', () => {
|
|
|
143
143
|
getCookieSpy.and.returnValue(
|
|
144
144
|
Date.now() - AUTOLOGIN_COOKIE_TTL - 1000
|
|
145
145
|
);
|
|
146
|
-
|
|
146
|
+
attemptAutoLoginJob();
|
|
147
147
|
});
|
|
148
148
|
itShouldCallThirdPartyCookieStrategy();
|
|
149
149
|
itShouldNotNavigateAway();
|
|
@@ -157,7 +157,7 @@ describe('attemptAutoLoginJob', () => {
|
|
|
157
157
|
store.merge('state', {
|
|
158
158
|
emergencyMode: ['aid'],
|
|
159
159
|
});
|
|
160
|
-
|
|
160
|
+
attemptAutoLoginJob();
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
it('should not try third party auto login', () => {
|
|
@@ -194,7 +194,7 @@ describe('attemptPaywallAutoLogin', () => {
|
|
|
194
194
|
});
|
|
195
195
|
});
|
|
196
196
|
store.set('state', { isLoggedIn: true });
|
|
197
|
-
|
|
197
|
+
attemptPaywallAutoLogin();
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
200
|
|
|
@@ -221,7 +221,7 @@ describe('attemptPaywallAutoLogin', () => {
|
|
|
221
221
|
delete global.top; // Set window.top to something other than window.self
|
|
222
222
|
// @ts-ignore
|
|
223
223
|
global.top = {};
|
|
224
|
-
|
|
224
|
+
attemptPaywallAutoLogin();
|
|
225
225
|
});
|
|
226
226
|
afterEach(() => {
|
|
227
227
|
// @ts-ignore
|
|
@@ -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
|
});
|
|
@@ -244,7 +244,7 @@ describe('attemptPaywallAutoLogin', () => {
|
|
|
244
244
|
describe('when tried within the last minute', () => {
|
|
245
245
|
beforeEach(async () => {
|
|
246
246
|
getCookieSpy.and.returnValue(Date.now());
|
|
247
|
-
|
|
247
|
+
attemptPaywallAutoLogin();
|
|
248
248
|
});
|
|
249
249
|
itShouldNotNavigateAway();
|
|
250
250
|
});
|
|
@@ -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
|
@@ -78,7 +78,14 @@ 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
90
|
return true;
|
|
84
91
|
});
|