@txstate-mws/sveltekit-utils 1.3.4 → 1.3.5
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/dist/unifiedauth.js +7 -2
- package/package.json +1 -1
package/dist/unifiedauth.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { redirect } from '@sveltejs/kit';
|
|
2
2
|
import { isBlank, Cache } from 'txstate-utils';
|
|
3
3
|
import { decodeJwt } from 'jose';
|
|
4
|
+
import { invalidateAll } from '$app/navigation';
|
|
4
5
|
const mayImpersonateAnyCache = new Cache(async (token, api) => {
|
|
5
6
|
const authUrl = new URL(api.authRedirect);
|
|
6
7
|
const mayImpersonateUrl = new URL('/mayImpersonate', authUrl.origin);
|
|
@@ -64,6 +65,11 @@ export const unifiedAuth = {
|
|
|
64
65
|
}
|
|
65
66
|
throw redirect(302, redirectUrl);
|
|
66
67
|
}
|
|
68
|
+
window.addEventListener('pageshow', (event) => {
|
|
69
|
+
if (event.persisted && isBlank(api.token)) {
|
|
70
|
+
invalidateAll();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
67
73
|
if (!opts?.allowUnauthenticated)
|
|
68
74
|
this.requireAuth(api, input);
|
|
69
75
|
},
|
|
@@ -84,8 +90,7 @@ export const unifiedAuth = {
|
|
|
84
90
|
api.token = undefined;
|
|
85
91
|
sessionStorage.removeItem('token');
|
|
86
92
|
sessionStorage.removeItem('originalToken');
|
|
87
|
-
|
|
88
|
-
window.location.replace(authRedirect.toString());
|
|
93
|
+
location.href = authRedirect.toString();
|
|
89
94
|
},
|
|
90
95
|
requireAuth(api, input) {
|
|
91
96
|
if (!api.token) {
|