Skip to content

Don't set email if invalid in user:add command#28426

Merged
PVince81 merged 1 commit into
masterfrom
validate-email
Aug 1, 2017
Merged

Don't set email if invalid in user:add command#28426
PVince81 merged 1 commit into
masterfrom
validate-email

Conversation

@tomneedham

Copy link
Copy Markdown
Contributor

Description

Related Issue

#28425

Motivation and Context

Otherwise invalid emails can be set by accident

How Has This Been Tested?

OCC commands with invalid and valid email addreses

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@tomneedham tomneedham added this to the development milestone Jul 18, 2017
@tomneedham tomneedham requested a review from phil-davis July 18, 2017 09:33

@phil-davis phil-davis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works
the question is now, should it work like this (create the user, but just not set any email address), or
not create the user at all

@phil-davis

Copy link
Copy Markdown
Contributor

@PVince81 @DeepDiver1975 or whoever, what do you think should be the behavior when the email address is not valid?
Add the user anyway, without an email address, or give an error and do not add the user at all?

@PVince81

Copy link
Copy Markdown
Contributor

I'd say don't add the user at all as the whole user entity failed validation by having a wrong email address

Comment thread core/Command/User/Add.php Outdated
// Validate first
if(!$this->mailer->validateMailAddress($input->getOption('email'))) {
// Invalid! Error
$output->writeln('<error>Invalid email address supplied</error>');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please throw / return error code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation will have to happen before:

$this->userManager->createUser()

and throw an error there, before the user is created.
Then the code to create the email address happen around here, after the user is created.

@PVince81 PVince81 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@PVince81 PVince81 merged commit ae2451c into master Aug 1, 2017
@PVince81 PVince81 deleted the validate-email branch August 1, 2017 08:52
@PVince81

PVince81 commented Aug 1, 2017

Copy link
Copy Markdown
Contributor

@tomneedham please backport to stable10

@lock

lock Bot commented Aug 3, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants