fix: fix token storage after login

Save keystone_token after login, earlier than profile api

Change-Id: Ia65a2c386f3f04ebf61b030c28d9efab17d6558d
This commit is contained in:
Jingwei.Zhang 2022-04-22 11:15:37 +08:00
parent c0727c95d8
commit 3091c21e6e

View File

@ -103,9 +103,15 @@ export class RootStore {
this.routing.push(`${pathname}?${getQueryString(newParams)}`);
};
setKeystoneToken(result) {
const { keystone_token } = result || {};
setLocalStorageItem('keystone_token', keystone_token);
}
@action
async login(params) {
await this.client.login(params);
const result = await this.client.login(params);
this.setKeystoneToken(result);
return this.getUserProfileAndPolicy();
}
@ -133,7 +139,6 @@ export class RootStore {
this.user = user;
this.policies = policies;
const {
keystone_token,
endpoints = {},
license = {},
version = '',
@ -144,7 +149,7 @@ export class RootStore {
this.license = license || {};
this.version = version;
this.updateUserRoles(user);
setLocalStorageItem('keystone_token', keystone_token);
this.setKeystoneToken(user);
this.endpoints = endpoints;
}
@ -179,7 +184,7 @@ export class RootStore {
this.client.policies.list(),
]);
this.updateUser(profile, policies.policies || []);
this.getNeutronExtensions();
return this.getNeutronExtensions();
}
@action
@ -229,8 +234,7 @@ export class RootStore {
this.user = null;
const result = await this.client.switchProject(projectId, domainId);
this.clearData();
const { keystone_token } = result;
setLocalStorageItem('keystone_token', keystone_token);
this.setKeystoneToken(result);
return this.getUserProfileAndPolicy();
}