open-vault/ui/app/controllers/vault.js
Matthew Irish 3da6487cf4
UI - support redirecting to an intended URL after authentication (#7088)
* add redirect_to query param

* alias auth controller state to vault controller where the query param is defined

* capture the current url before redirecting a user to auth if they're being redirected

* consume and reset the redirectTo query param when authenticating

* make sure that the current url when logging out does not get set as the redirect_to query param

* add unit tests for the mixin and make it so that redirects from the root don't end up in redirect_to

* acceptance tests for redirect
2019-08-01 18:50:43 -05:00

27 lines
791 B
JavaScript

import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import config from '../config/environment';
export default Controller.extend({
queryParams: [
{
wrappedToken: 'wrapped_token',
redirectTo: 'redirect_to',
},
],
wrappedToken: '',
redirectTo: '',
env: config.environment,
auth: service(),
store: service(),
activeCluster: computed('auth.activeCluster', function() {
let id = this.get('auth.activeCluster');
return id ? this.get('store').peekRecord('cluster', id) : null;
}),
activeClusterName: computed('activeCluster', function() {
const activeCluster = this.get('activeCluster');
return activeCluster ? activeCluster.get('name') : null;
}),
});