Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand occ user reset password email validation #32569

Merged
merged 3 commits into from
Sep 4, 2018

Conversation

settermjd
Copy link
Contributor

@settermjd settermjd commented Sep 4, 2018

Description

Improves the email address validation performed when running occ user:resetpassword --email-link.

Related Issue

Motivation and Context

When I was documenting the changes that #32345 made, I found that when running occ user:resetpassword --email-link, an error message is displayed only if a user's password is null. However, if it was an empty string, then the error would not be thrown and the code would attempt to send an email using the invalid email address.

I created these changes to ensure that only valid email addresses are able to be used.

💁 fwiw, I'm not totally sure that using a Zend\Validator\EmailAddress object directly is the best approach.

How Has This Been Tested?

  • Updated the covering tests and ensured that they all passed.

Screenshots (if appropriate):

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)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)

Previously, when calling occ user:resetpassword --send-email, if the
email address was null, then an error would be shown on the console, but
not if the password was empty. So this commit extends the email address
validation to show the error if the email address is null or empty.
zend-validator provides a well written and tested library for
validation. I specifically added it so that I could perform better email
address validation in ResetPasswordTest::hasValidEmailAddress.
I refactored the existing email address validation, which only tests if
the email address is a null or an empty string, to use
Zend\Validator\EmailAddress. By doing so, the email address can be
tested far more exhaustively than it is, currently.
@codecov
Copy link

codecov bot commented Sep 4, 2018

Codecov Report

Merging #32569 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #32569      +/-   ##
============================================
+ Coverage     64.09%    64.1%   +<.01%     
- Complexity    18654    18655       +1     
============================================
  Files          1177     1177              
  Lines         70232    70234       +2     
  Branches       1270     1270              
============================================
+ Hits          45018    45020       +2     
  Misses        24844    24844              
  Partials        370      370
Flag Coverage Δ Complexity Δ
#javascript 52.89% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 65.37% <100%> (ø) 18655 <1> (+1) ⬆️
Impacted Files Coverage Δ Complexity Δ
core/Command/User/ResetPassword.php 67.05% <100%> (+0.79%) 19 <1> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3aa4ddb...9e4caa4. Read the comment docs.

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

👍

@PVince81 PVince81 merged commit 304407e into master Sep 4, 2018
@PVince81 PVince81 deleted the expand-occ-user-reset-password-email-validation branch September 4, 2018 14:47
@PVince81
Copy link
Contributor

PVince81 commented Sep 4, 2018

@settermjd please backport

@phil-davis
Copy link
Contributor

@settermjd did a backport happen?
There is no reference here, and the backport-request label is still on.

@phil-davis
Copy link
Contributor

@settermjd @PVince81 I don't see any backport for this???

@phil-davis
Copy link
Contributor

Backport stable10 #33945

@settermjd
Copy link
Contributor Author

Thanks for backporting @phil-davis.

@davitol
Copy link
Contributor

davitol commented Jan 4, 2019

@settermjd Those are the options available for user:resetpassword command

occ user:resetpassword --help
Usage:
  user:resetpassword [options] [--] <user>

Arguments:
  user                     The user's name.

Options:
      --password-from-env  Read the password from the OC_PASS environment variable.
      --send-email         The email-id set while creating the user, will be used to send link for password reset. This option will also display the link sent to user.
      --output-link        The link to reset the password will be displayed.
  -h, --help               Display this help message
  -q, --quiet              Do not output any message
  -V, --version            Display this application version
      --ansi               Force ANSI output
      --no-ansi            Disable ANSI output
  -n, --no-interaction     Do not ask any interactive question
      --no-warnings        Skip global warnings, show command output only
  -v|vv|vvv, --verbose     Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Resets the password of the named user.

In the OP it says run command occ user:resetpassword --email-link . Can you please clarify me if it is the command I should run? Thanks in advance.

@davitol davitol mentioned this pull request Jan 4, 2019
39 tasks
@lock lock bot locked as resolved and limited conversation to collaborators Jan 4, 2020
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