mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 11:37:32 +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.
(cherry picked from commit 51210c8e34
)
This commit is contained in:

committed by
Livio Spring

parent
ce29a78d1b
commit
fd57ffc345
@@ -261,27 +261,33 @@ export class GrpcAuthService {
|
|||||||
this.setActiveOrg(orgs[0]);
|
this.setActiveOrg(orgs[0]);
|
||||||
return Promise.resolve(orgs[0]);
|
return Promise.resolve(orgs[0]);
|
||||||
} else {
|
} else {
|
||||||
|
// throw error if the org was specifically requested but not found
|
||||||
return Promise.reject(new Error('requested organization not found'));
|
return Promise.reject(new Error('requested organization not found'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let orgs = this.cachedOrgs.getValue();
|
let orgs = this.cachedOrgs.getValue();
|
||||||
|
|
||||||
const org = this.storage.getItem<Org.AsObject>(StorageKey.organization, StorageLocation.local);
|
const org = this.storage.getItem<Org.AsObject>(StorageKey.organization, StorageLocation.local);
|
||||||
|
|
||||||
if (org) {
|
if (org) {
|
||||||
const orgQuery = new OrgQuery();
|
orgs = (await this.listMyProjectOrgs(ORG_LIMIT, 0)).resultList;
|
||||||
const orgIdQuery = new OrgIDQuery();
|
this.cachedOrgs.next(orgs);
|
||||||
orgIdQuery.setId(org.id);
|
|
||||||
orgQuery.setIdQuery(orgIdQuery);
|
|
||||||
|
|
||||||
const specificOrg = (await this.listMyProjectOrgs(ORG_LIMIT, 0, [orgQuery])).resultList;
|
const find = this.cachedOrgs.getValue().find((tmp) => tmp.id === id);
|
||||||
if (specificOrg.length === 1) {
|
if (find) {
|
||||||
this.setActiveOrg(specificOrg[0]);
|
this.setActiveOrg(find);
|
||||||
return Promise.resolve(specificOrg[0]);
|
return Promise.resolve(find);
|
||||||
} else {
|
} else {
|
||||||
orgs = (await this.listMyProjectOrgs(ORG_LIMIT, 0)).resultList;
|
const orgQuery = new OrgQuery();
|
||||||
this.cachedOrgs.next(orgs);
|
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 {
|
} else {
|
||||||
orgs = (await this.listMyProjectOrgs(ORG_LIMIT, 0)).resultList;
|
orgs = (await this.listMyProjectOrgs(ORG_LIMIT, 0)).resultList;
|
||||||
|
Reference in New Issue
Block a user