Skip to content

Commit

Permalink
feat: Add public route to reset local data
Browse files Browse the repository at this point in the history
When the stack serves the login page, we take this opportunity to remove
any remaining local data, i.e. indexedDB and localstorage data.

See how it is done for the stack part:
cozy/cozy-stack#4483
  • Loading branch information
paultranvan committed Nov 4, 2024
1 parent 9491e0e commit 43fb9bd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions manifest.webapp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"folder": "/",
"index": "index.html",
"public": false
},
"/reset": {
"folder": "/reset",
"index": "index.html",
"public": true
}
},
"intents": [
Expand Down
10 changes: 7 additions & 3 deletions rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default defineConfig({
output: {
cleanDistPath: true,
distPath: {
root: 'build'
}
root: 'build',
},
},
html: {
template: './src/targets/browser/index.ejs',
Expand Down Expand Up @@ -49,7 +49,11 @@ export default defineConfig({
},
{
from: 'icon.svg'
}
},
{
from: 'src/targets/public/index.html',
to: 'reset/index.html'
},
],
})
]
Expand Down
1 change: 0 additions & 1 deletion src/targets/browser/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json" crossOrigin="use-credentials">
<meta name="color-scheme" content="light dark" />
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand Down
15 changes: 15 additions & 0 deletions src/targets/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<script>
// Remove all indexedDB databases
window.indexedDB.databases().then(function(databases) {
databases.forEach(function(db) {
console.log('Delete indexedDB database : ', db.name);
window.indexedDB.deleteDatabase(db.name)
})
})
// Remove localstorage
window.localStorage.clear()
</script>
</head>
</html>

0 comments on commit 43fb9bd

Please sign in to comment.