diff --git a/client/src/app.js b/client/src/app.js index 54fe12309e..23ab10a9c0 100644 --- a/client/src/app.js +++ b/client/src/app.js @@ -592,11 +592,23 @@ define( this.auth = this.storage.get('user', 'auth') || null; this.baseController.on('login', data => { - this.auth = Base64.encode(data.auth.userName + ':' + data.auth.token); + let userId = data.user.id; + let userName = data.auth.userName; + let token = data.auth.token; + + this.auth = Base64.encode(userName + ':' + token); + + let lastUserId = this.storage.get('user', 'lastUserId'); + + if (lastUserId !== userId) { + this.metadata.clearCache(); + this.language.clearCache(); + } this.storage.set('user', 'auth', this.auth); + this.storage.set('user', 'lastUserId', userId); - this.setCookieAuth(data.auth.userName, data.auth.token); + this.setCookieAuth(userName, token); this.initUserData(data, () => this.trigger('auth')); }); diff --git a/client/src/metadata.js b/client/src/metadata.js index d6e30ef2df..e96b96c6e4 100644 --- a/client/src/metadata.js +++ b/client/src/metadata.js @@ -137,6 +137,14 @@ define('metadata', [], function () { } }, + clearCache: function () { + if (!this.cache) { + return; + } + + this.cache.clear('app', 'metadata'); + }, + getScopeList: function () { let scopes = this.get('scopes') || {}; let scopeList = [];