mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-04 23:45:07 +00:00
fix(console): fill cachedorgs when read from local storage (#8363)
This fixes a problem where the org settings were hidden. The console reads the context from either a query param or the local storage. When one context was found, it executed a single request with orgId filter. This let to a single org and then to a hidden org setting, as we hide org settings for instances with a single result.
This commit is contained in:
parent
3f77d87b52
commit
51210c8e34
@ -261,27 +261,33 @@ export class GrpcAuthService {
|
||||
this.setActiveOrg(orgs[0]);
|
||||
return Promise.resolve(orgs[0]);
|
||||
} else {
|
||||
// throw error if the org was specifically requested but not found
|
||||
return Promise.reject(new Error('requested organization not found'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let orgs = this.cachedOrgs.getValue();
|
||||
|
||||
const org = this.storage.getItem<Org.AsObject>(StorageKey.organization, StorageLocation.local);
|
||||
|
||||
if (org) {
|
||||
const orgQuery = new OrgQuery();
|
||||
const orgIdQuery = new OrgIDQuery();
|
||||
orgIdQuery.setId(org.id);
|
||||
orgQuery.setIdQuery(orgIdQuery);
|
||||
orgs = (await this.listMyProjectOrgs(ORG_LIMIT, 0)).resultList;
|
||||
this.cachedOrgs.next(orgs);
|
||||
|
||||
const specificOrg = (await this.listMyProjectOrgs(ORG_LIMIT, 0, [orgQuery])).resultList;
|
||||
if (specificOrg.length === 1) {
|
||||
this.setActiveOrg(specificOrg[0]);
|
||||
return Promise.resolve(specificOrg[0]);
|
||||
const find = this.cachedOrgs.getValue().find((tmp) => tmp.id === id);
|
||||
if (find) {
|
||||
this.setActiveOrg(find);
|
||||
return Promise.resolve(find);
|
||||
} else {
|
||||
orgs = (await this.listMyProjectOrgs(ORG_LIMIT, 0)).resultList;
|
||||
this.cachedOrgs.next(orgs);
|
||||
const orgQuery = new OrgQuery();
|
||||
const orgIdQuery = new OrgIDQuery();
|
||||
orgIdQuery.setId(org.id);
|
||||
orgQuery.setIdQuery(orgIdQuery);
|
||||
|
||||
const specificOrg = (await this.listMyProjectOrgs(ORG_LIMIT, 0, [orgQuery])).resultList;
|
||||
if (specificOrg.length === 1) {
|
||||
this.setActiveOrg(specificOrg[0]);
|
||||
return Promise.resolve(specificOrg[0]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
orgs = (await this.listMyProjectOrgs(ORG_LIMIT, 0)).resultList;
|
||||
|
Loading…
Reference in New Issue
Block a user