diff --git a/ui/app/components/auth-form.js b/ui/app/components/auth-form.js index a2ebe58449a4..2790508a4e20 100644 --- a/ui/app/components/auth-form.js +++ b/ui/app/components/auth-form.js @@ -3,7 +3,21 @@ import { supportedAuthBackends } from 'vault/helpers/supported-auth-backends'; const BACKENDS = supportedAuthBackends(); const { computed, inject } = Ember; -export default Ember.Component.extend({ +const attributesForSelectedAuthBackend = { + token: ['token'], + userpass: ['username', 'password'], + ldap: ['username', 'password'], + github: ['username', 'password'], + okta: ['username', 'password'], +}; + +const DEFAULTS = { + token: null, + username: null, + password: null, +}; + +export default Ember.Component.extend(DEFAULTS, { classNames: ['auth-form'], routing: inject.service('-routing'), auth: inject.service(), @@ -14,6 +28,21 @@ export default Ember.Component.extend({ this.$('li.is-active').get(0).scrollIntoView(); }, + didReceiveAttrs() { + this._super(...arguments); + let newMethod = this.get('selectedAuthType'); + let oldMethod = this.get('oldSelectedAuthType'); + + if (oldMethod && oldMethod !== newMethod) { + this.resetDefaults(); + } + this.set('oldSelectedAuthType', newMethod); + }, + + resetDefaults() { + this.setProperties(DEFAULTS); + }, + cluster: null, redirectTo: null, @@ -22,9 +51,9 @@ export default Ember.Component.extend({ return BACKENDS.findBy('type', this.get('selectedAuthType')); }), - providerComponentName: Ember.computed('selectedAuthBackend.type', function() { - const type = Ember.String.dasherize(this.get('selectedAuthBackend.type')); - return `auth-form/${type}`; + providerPartialName: Ember.computed('selectedAuthType', function() { + const type = Ember.String.dasherize(this.get('selectedAuthType')); + return `partials/auth-form/${type}`; }), hasCSPError: computed.alias('csp.connectionViolations.firstObject'), @@ -45,15 +74,18 @@ export default Ember.Component.extend({ }, actions: { - doSubmit(data) { + doSubmit() { + let data = {}; this.setProperties({ loading: true, error: null, }); - const targetRoute = this.get('redirectTo') || 'vault.cluster'; - //const {password, token, username} = data; - const backend = this.get('selectedAuthBackend.type'); - const path = this.get('customPath'); + let targetRoute = this.get('redirectTo') || 'vault.cluster'; + let backend = this.get('selectedAuthBackend.type'); + let path = this.get('customPath'); + let attributes = attributesForSelectedAuthBackend[backend]; + + data = Ember.assign(data, this.getProperties(...attributes)); if (this.get('useCustomPath') && path) { data.path = path; } diff --git a/ui/app/components/download-button.js b/ui/app/components/download-button.js index 72fee1106ef4..2e2847c887fa 100644 --- a/ui/app/components/download-button.js +++ b/ui/app/components/download-button.js @@ -12,7 +12,7 @@ export default Ember.Component.extend({ return `${this.get('filename')}-${new Date().toISOString()}.${this.get('extension')}`; }), - fileLike: computed('data', 'mime', 'strigify', 'download', function() { + fileLike: computed('data', 'mime', 'stringify', 'download', function() { let file; let data = this.get('data'); let filename = this.get('download'); diff --git a/ui/app/styles/components/shamir-progress.scss b/ui/app/styles/components/shamir-progress.scss index 4bb418328a76..1169b45a4db7 100644 --- a/ui/app/styles/components/shamir-progress.scss +++ b/ui/app/styles/components/shamir-progress.scss @@ -1,11 +1,12 @@ .shamir-progress { .shamir-progress-progress { display: inline-block; + margin-top: $size-10; margin-right: $size-8; } .progress { box-shadow: 0 0 0 4px $progress-bar-background-color; - display: inline; - width: 150px; + margin-top: $size-10; + min-width: 90px; } } diff --git a/ui/app/templates/components/auth-form.hbs b/ui/app/templates/components/auth-form.hbs index 73b35345a476..2d94e536adfd 100644 --- a/ui/app/templates/components/auth-form.hbs +++ b/ui/app/templates/components/auth-form.hbs @@ -1,7 +1,7 @@ -
- If this backend was mounted using a non-default path, enter it here. -
- {{/if}} -