ui: Misc SSO w/Namespace amends (#7851)

* ui: If an auth-method is in another namespace than default, make that clear

* Pass through the namespace of the auth method rather than use the current

* Make sure we refresh the application route, before redirecting

This ensure that the nspaces and are refreshed in the main nav menu
This commit is contained in:
John Cowen 2020-05-12 12:51:49 +01:00 committed by John Cowen
parent 319301abe8
commit 74f1a3917e
3 changed files with 21 additions and 10 deletions

View File

@ -90,7 +90,7 @@
<State @matches="loading"> <State @matches="loading">
<TokenSource <TokenSource
@dc={{dc}} @dc={{dc}}
@nspace={{nspace}} @nspace={{or value.Namespace nspace}}
@type={{if value.Name 'oidc' 'secret'}} @type={{if value.Name 'oidc' 'secret'}}
@value={{if value.Name value.Name value}} @value={{if value.Name value.Name value}}
@onchange={{action onsubmit}} @onchange={{action onsubmit}}

View File

@ -11,7 +11,7 @@
type="button" class={{concat item.Kind '-oidc-provider'}} type="button" class={{concat item.Kind '-oidc-provider'}}
onclick={{action onchange item}} onclick={{action onchange item}}
> >
Continue with {{or item.DisplayName item.Name}} Continue with {{or item.DisplayName item.Name}}{{#if (not-eq item.Namespace 'default')}} ({{item.Namespace}}){{/if}}
</button> </button>
</li> </li>
{{/each}} {{/each}}
@ -26,7 +26,9 @@
@selected={{item}} @selected={{item}}
@searchEnabled={{false}} @searchEnabled={{false}}
@options={{items}} as |item|> @options={{items}} as |item|>
<span class={{concat item.Kind '-oidc-provider'}}>{{or item.DisplayName item.Name}}</span> <span class={{concat item.Kind '-oidc-provider'}}>
{{or item.DisplayName item.Name}}{{#if (not-eq item.Namespace 'default')}} ({{item.Namespace}}){{/if}}
</span>
</PowerSelect> </PowerSelect>
</label> </label>
<button <button

View File

@ -44,13 +44,22 @@ export default Controller.extend({
} }
const routeName = this.router.currentRoute.name; const routeName = this.router.currentRoute.name;
const route = getOwner(this).lookup(`route:${routeName}`); const route = getOwner(this).lookup(`route:${routeName}`);
const router = this.router;
// Refresh the application route
return getOwner(this)
.lookup('route:application')
.refresh()
.promise.then(() => {
// We use transitionable here as refresh doesn't work if you are on an error page // We use transitionable here as refresh doesn't work if you are on an error page
// which is highly likely to happen here (403s) // which is highly likely to happen here (403s)
if (routeName !== this.router.currentRouteName) { if (routeName !== router.currentRouteName || typeof params.nspace !== 'undefined') {
return route.transitionTo(...transitionable(this.router, params, getOwner(this))); return route.transitionTo(
...transitionable(router.currentRoute, params, getOwner(this))
);
} else { } else {
return route.refresh(); return route.refresh();
} }
});
}, },
e.type, e.type,
function(type, e) { function(type, e) {