Merge pull request #50997 from nextcloud/backport/50956/stable30

This commit is contained in:
Maksim Sukharev 2025-02-25 17:34:58 +01:00 committed by GitHub
commit 3262ca0649
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 28 additions and 13 deletions

View file

@ -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,
})
@ -62,6 +64,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
*

View file

@ -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 {

4
dist/core-login.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
dist/core-main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long