Merge pull request #3261 from vincent99/master

Delete keys option on change password
This commit is contained in:
Vincent Fiduccia 2019-08-16 13:53:01 -07:00 committed by GitHub
commit ea8f751d4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 24 deletions

View File

@ -4,6 +4,7 @@ import { get, set, computed, observer } from '@ember/object';
import { inject as service } from '@ember/service';
import { later, run } from '@ember/runloop';
import { randomStr } from 'shared/utils/util';
import { resolve, all } from 'rsvp';
const CHANGE = 'change';
const SET = 'set';
@ -16,17 +17,19 @@ export default Component.extend({
access: service(),
layout,
showCurrent: true,
generate: false,
setOrChange: CHANGE,
editLabel: 'modalEditPassword.actionButton',
currentPassword: null,
user: null,
showCurrent: true,
generate: false,
setOrChange: CHANGE,
editLabel: 'modalEditPassword.actionButton',
currentPassword: null,
user: null,
showDeleteTokens: false,
confirmBlurred: false,
serverErrors: null,
password: null,
confirm: null,
confirmBlurred: false,
serverErrors: null,
password: null,
confirm: null,
deleteTokens: false,
didReceiveAttrs() {
if ( get(this, 'generate') ) {
@ -69,16 +72,31 @@ export default Component.extend({
promise = user.doAction('setpassword', { newPassword: neu.trim(), });
}
return promise.then(() => get(this, 'access').loadMe()
.then(() => {
get(this, 'complete')(true);
later(this, () => {
if ( this.isDestroyed || this.isDestroying ) {
return;
}
cb(true);
}, 1000);
})).catch((err) => {
return promise.then(() => get(this, 'access').loadMe().then(() => {
if ( get(this, 'deleteTokens') ) {
return get(this, 'globalStore').findAll('token').then((tokens) => {
const promises = [];
tokens.forEach((token) => {
if ( !token.current ) {
promises.push(token.delete());
}
});
return all(promises);
});
} else {
return resolve();
}
}).then(() => {
get(this, 'complete')(true);
later(this, () => {
if ( this.isDestroyed || this.isDestroying ) {
return;
}
cb(true);
}, 1000);
})).catch((err) => {
set(this, 'serverErrors', [err.message]);
get(this, 'complete')(false);
cb(false);

View File

@ -7,6 +7,10 @@
style="display: none;"
/>
<div class="content">
{{#if showDeleteTokens}}
<label>{{input type="checkbox" checked=deleteTokens}} {{t 'modalEditPassword.deleteTokens'}}</label>
{{/if}}
{{#if showCurrent}}
<div class="row mb-20">
<div class="col span-12">

View File

@ -7,6 +7,7 @@
{{input-edit-password
complete=(action "complete")
showCurrent=true
showDeleteTokens=true
cancel=(action "cancel")
editButton='modalEditPassword.actionButton'
user=user

View File

@ -165,6 +165,7 @@
@value={{config.kubernetesVersion}}
@versions={{versionChoices}}
@clusterTemplateQuestions={{clusterTemplateQuestions}}
@showNotAllowed=true
/>
</CheckOverrideAllowed>
</div>

View File

@ -23,6 +23,7 @@ export default Component.extend({
disabled: false,
value: null,
mode: 'new',
showNotAllowed: false,
editing: equal('mode', 'edit'),
isView: equal('mode', 'view'),
@ -135,11 +136,13 @@ export default Component.extend({
};
}
} else {
const suffix = ( this.showNotAllowed ? 'formVersions.notallowed' : 'formVersions.unsupported' );
if (gt(version, coerceVersion(maxVersion))) {
if (overrideMatch && !isEmpty(overrideMatch.satisfies)) {
out = {
disabled: true,
label: `${ label } ${ this.intl.t('formVersions.unsupported') }`,
label: `${ label } ${ this.intl.t(suffix) }`,
value: v
};
} else {
@ -152,7 +155,7 @@ export default Component.extend({
} else if (lt(version, coerceVersion(maxVersion))) {
out = {
disabled: true,
label: `${ label } ${ this.intl.t('formVersions.unsupported') }`,
label: `${ label } ${ this.intl.t(suffix) }`,
value: v
};
}

View File

@ -1,6 +1,6 @@
{
"name": "ui",
"version": "2.3.2",
"version": "2.3.3",
"private": true,
"repository": "https://github.com/rancher/ui",
"license": "Apache-2.0",

View File

@ -5579,7 +5579,8 @@ formVersions:
experimental: "(experimental)"
dotx: "Latest {minor} (allows patch version upgrades)"
downgrade: "(can't downgrade)"
unsupported: "(not allowed by template)"
notallowed: "(not allowed by template)"
unsupported: "(unsupported)"
formIstioHost:
prompt: Select a host...
@ -6154,6 +6155,7 @@ modalEditPassword:
mode:
generate: 'Use a new randomly generated password:'
manual: 'Set a specific password to use:'
deleteTokens: Delete all existing API keys
modalFeedback:
header: Welcome to {appName}!