aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaksim Sukharev <antreesy.web@gmail.com>2025-02-21 16:28:51 +0100
committerMaksim Sukharev <antreesy.web@gmail.com>2025-02-25 16:59:07 +0100
commit4a7531ea0f7bc4601b3052a46529386027dac21b (patch)
tree97837191beb1873dd09aa019d3f93f1dfa573cef
parent5c0af8565c3721db2f1b8bfb3c73008f3fda9f67 (diff)
downloadnextcloud-server-backport/50956/stable30.tar.gz
nextcloud-server-backport/50956/stable30.zip
fix: wipe local storages on log outbackport/50956/stable30
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
-rw-r--r--core/src/utils/xhr-request.js20
-rw-r--r--core/src/views/Login.vue9
2 files changed, 22 insertions, 7 deletions
diff --git a/core/src/utils/xhr-request.js b/core/src/utils/xhr-request.js
index 68641ebc006..c256313df31 100644
--- a/core/src/utils/xhr-request.js
+++ b/core/src/utils/xhr-request.js
@@ -5,6 +5,7 @@
import { getCurrentUser } from '@nextcloud/auth'
import { generateUrl, getRootUrl } from '@nextcloud/router'
+import logger from '../logger.js'
/**
*
@@ -51,6 +52,7 @@ async function checkLoginStatus() {
const { status } = await window.fetch(generateUrl('/apps/files'))
if (status === 401) {
console.warn('User session was terminated, forwarding to login page.')
+ await wipeBrowserStorages()
window.location = generateUrl('/login?redirect_url={url}', {
url: window.location.pathname + window.location.search + window.location.hash,
})
@@ -63,6 +65,24 @@ async function checkLoginStatus() {
}
/**
+ * Clear all Browser storages connected to current origin.
+ * @returns {Promise<void>}
+ */
+export async function wipeBrowserStorages() {
+ try {
+ window.localStorage.clear()
+ window.sessionStorage.clear()
+ const indexedDBList = await window.indexedDB.databases()
+ for (const indexedDB of indexedDBList) {
+ await window.indexedDB.deleteDatabase(indexedDB.name)
+ }
+ logger.debug('Browser storages cleared')
+ } catch (error) {
+ logger.error('Could not clear browser storages', { error })
+ }
+}
+
+/**
* Intercept XMLHttpRequest and fetch API calls to add X-Requested-With header
*
* This is also done in @nextcloud/axios but not all requests pass through that
diff --git a/core/src/views/Login.vue b/core/src/views/Login.vue
index d6c88d607ad..832a40df2f5 100644
--- a/core/src/views/Login.vue
+++ b/core/src/views/Login.vue
@@ -113,16 +113,11 @@ import ResetPassword from '../components/login/ResetPassword.vue'
import UpdatePassword from '../components/login/UpdatePassword.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
+import { wipeBrowserStorages } from '../utils/xhr-request.js'
const query = queryString.parse(location.search)
if (query.clear === '1') {
- try {
- window.localStorage.clear()
- window.sessionStorage.clear()
- console.debug('Browser storage cleared')
- } catch (e) {
- console.error('Could not clear browser storage', e)
- }
+ wipeBrowserStorages()
}
export default {