Skip to content

Commit

Permalink
fixup! Fix load factory flow in the case with policies.create=peruser
Browse files Browse the repository at this point in the history
  • Loading branch information
olexii4 committed Oct 10, 2019
1 parent f85c65b commit 52e9f0c
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,26 +245,26 @@ export class LoadFactoryController {
case 'peruser' :
workspace = this.lodash.find(this.workspaces, (w: che.IWorkspace) => {
if (this.factory.id) {
return this.factory.id === (w.attributes as any).factoryId;
} else if (this.routeParams.url){
const factoryUrl = (w.attributes as any).factoryurl;
return this.factory.id === w.attributes.factoryId;
} else if (this.routeParams.url) {
const factoryUrl = w.attributes.factoryurl;
// compare factory URL and route params
if (angular.isDefined(factoryUrl)) {
const factoryUrlObj = new (window as any).URL(factoryUrl);
const pathIsCorrect = `${factoryUrlObj.origin}${factoryUrlObj.pathname}` === this.routeParams.url;
if (pathIsCorrect === false) {
const isPathCorrect = `${factoryUrlObj.origin}${factoryUrlObj.pathname}` === this.routeParams.url;
if (isPathCorrect === false) {
return false;
}

let factoryUrlParamsNumber = 0;
let hasExtraKey = false;
factoryUrlObj.searchParams.forEach((volume: string, key: string) => {
for (const [key, value] of factoryUrlObj.searchParams) {
if (hasExtraKey) {
return;
}
factoryUrlParamsNumber++;
hasExtraKey = this.routeParams[key] !== volume;
});
hasExtraKey = this.routeParams[key] !== value;
}
if (hasExtraKey) {
return false;
}
Expand Down

0 comments on commit 52e9f0c

Please sign in to comment.