mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
User management - email and name should be optional (#24842)
Fixes #17952
This commit is contained in:
parent
8cbafdf5fe
commit
e0b8cdf859
3 changed files with 22 additions and 17 deletions
|
@ -142,21 +142,12 @@ class EditUserUI extends Component {
|
|||
});
|
||||
}
|
||||
};
|
||||
fullnameError = () => {
|
||||
const { full_name } = this.state.user;
|
||||
if (full_name !== null && !full_name) {
|
||||
return this.props.intl.formatMessage({
|
||||
id: "xpack.security.management.users.editUser.fullNameRequiredErrorMessage",
|
||||
defaultMessage: "Full name is required"
|
||||
});
|
||||
}
|
||||
};
|
||||
emailError = () => {
|
||||
const { email } = this.state.user;
|
||||
if (email !== null && (!email || !email.match(validEmailRegex))) {
|
||||
if (email !== null && email !== '' && !email.match(validEmailRegex)) {
|
||||
return this.props.intl.formatMessage({
|
||||
id: "xpack.security.management.users.editUser.validEmailRequiredErrorMessage",
|
||||
defaultMessage: "A valid email address is required"
|
||||
defaultMessage: "Email address is invalid"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -365,8 +356,6 @@ class EditUserUI extends Component {
|
|||
const { user, isNewUser } = this.state;
|
||||
return (
|
||||
!user.username ||
|
||||
!user.full_name ||
|
||||
!user.email ||
|
||||
this.emailError() ||
|
||||
(isNewUser && (this.passwordError() || this.confirmPasswordError()))
|
||||
);
|
||||
|
@ -490,8 +479,6 @@ class EditUserUI extends Component {
|
|||
{reserved ? null : (
|
||||
<Fragment>
|
||||
<EuiFormRow
|
||||
isInvalid={!!this.fullnameError()}
|
||||
error={this.fullnameError()}
|
||||
label={intl.formatMessage({
|
||||
id: "xpack.security.management.users.editUser.fullNameFormRowLabel",
|
||||
defaultMessage: "Full name"
|
||||
|
|
|
@ -46,6 +46,19 @@ export default function ({ getService, getPageObjects }) {
|
|||
expect(users.Lee.reserved).to.be(false);
|
||||
});
|
||||
|
||||
it('should add new user with optional fields left empty', async function () {
|
||||
await PageObjects.security.addUser({
|
||||
username: 'OptionalUser', password: 'OptionalUserPwd',
|
||||
confirmPassword: 'OptionalUserPwd', save: true, roles: []
|
||||
});
|
||||
const users = indexBy(await PageObjects.security.getElasticsearchUsers(), 'username');
|
||||
log.debug('actualUsers = %j', users);
|
||||
expect(users.OptionalUser.roles).to.eql(['']);
|
||||
expect(users.OptionalUser.fullname).to.eql('');
|
||||
expect(users.OptionalUser.email).to.eql('');
|
||||
expect(users.OptionalUser.reserved).to.be(false);
|
||||
});
|
||||
|
||||
it('should delete user', async function () {
|
||||
const alertMsg = await PageObjects.security.deleteUser('Lee');
|
||||
log.debug('alertMsg = %s', alertMsg);
|
||||
|
|
|
@ -261,8 +261,13 @@ export function SecurityPageProvider({ getService, getPageObjects }) {
|
|||
await testSubjects.setValue('userFormUserNameInput', userObj.username);
|
||||
await testSubjects.setValue('passwordInput', userObj.password);
|
||||
await testSubjects.setValue('passwordConfirmationInput', userObj.confirmPassword);
|
||||
await testSubjects.setValue('userFormFullNameInput', userObj.fullname);
|
||||
await testSubjects.setValue('userFormEmailInput', userObj.email);
|
||||
if (userObj.fullname) {
|
||||
await testSubjects.setValue('userFormFullNameInput', userObj.fullname);
|
||||
}
|
||||
if (userObj.email) {
|
||||
await testSubjects.setValue('userFormEmailInput', userObj.email);
|
||||
}
|
||||
|
||||
log.debug('Add roles: ', userObj.roles);
|
||||
const rolesToAdd = userObj.roles || [];
|
||||
for (let i = 0; i < rolesToAdd.length; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue