@data-fair/lib-vue 1.10.4 → 1.11.0
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/session.js +11 -2
package/package.json
CHANGED
package/session.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FetchError } from 'ofetch'
|
|
1
2
|
import { reactive, computed, watch, inject, ref } from 'vue'
|
|
2
3
|
import { ofetch } from 'ofetch'
|
|
3
4
|
import { jwtDecode } from 'jwt-decode'
|
|
@@ -211,8 +212,16 @@ export async function getSession (initOptions) {
|
|
|
211
212
|
if (!ssr) {
|
|
212
213
|
window.localStorage.setItem('sd-keepalive' + options.sitePath, `${new Date().getTime()}`)
|
|
213
214
|
}
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
try {
|
|
216
|
+
await customFetch(`${options.directoryUrl}/api/auth/keepalive`, { method: 'POST' })
|
|
217
|
+
} catch (err) {
|
|
218
|
+
if (err instanceof FetchError && err.statusCode === 401) {
|
|
219
|
+
// this is expected if the session was deleted server side
|
|
220
|
+
} else {
|
|
221
|
+
throw err
|
|
222
|
+
}
|
|
223
|
+
readState()
|
|
224
|
+
}
|
|
216
225
|
}
|
|
217
226
|
const refreshSiteInfo = async () => {
|
|
218
227
|
const siteInfo = await customFetch(`${options.directoryUrl}/api/sites/_public`) ?? null
|