mirror of
https://github.com/documize/community.git
synced 2025-07-22 14:49:42 +02:00
Clear localstorage when user permissions change
This commit is contained in:
parent
bca306347d
commit
fc742a2282
1 changed files with 3 additions and 0 deletions
|
@ -16,6 +16,7 @@ import config from '../config/environment';
|
||||||
|
|
||||||
export default AjaxService.extend({
|
export default AjaxService.extend({
|
||||||
session: service(),
|
session: service(),
|
||||||
|
localStorage: service(),
|
||||||
host: config.apiHost,
|
host: config.apiHost,
|
||||||
namespace: config.apiNamespace,
|
namespace: config.apiNamespace,
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ export default AjaxService.extend({
|
||||||
|
|
||||||
// when unauthorized on local API AJAX calls, redirect to app root
|
// when unauthorized on local API AJAX calls, redirect to app root
|
||||||
if (status === 401 && is.not.undefined(appVersion) && is.not.includes(window.location.href, '/auth')) {
|
if (status === 401 && is.not.undefined(appVersion) && is.not.includes(window.location.href, '/auth')) {
|
||||||
|
this.get('localStorage').clearAll();
|
||||||
window.location.href = 'auth/login';
|
window.location.href = 'auth/login';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ export default AjaxService.extend({
|
||||||
let latest = JSON.parse(userUpdate);
|
let latest = JSON.parse(userUpdate);
|
||||||
|
|
||||||
if (!latest.active || user.editor !== latest.editor || user.admin !== latest.admin || user.viewUsers !== latest.viewUsers) {
|
if (!latest.active || user.editor !== latest.editor || user.admin !== latest.admin || user.viewUsers !== latest.viewUsers) {
|
||||||
|
this.get('localStorage').clearAll();
|
||||||
window.location.href = 'auth/login';
|
window.location.href = 'auth/login';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue