-
Notifications
You must be signed in to change notification settings - Fork 0
Fix the password reset logic and error handling #12
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
base: tuakiri-develop
Are you sure you want to change the base?
Conversation
|
Hi @Razorfang , Thanks, this is solid piece of work. The generating of the reset code upfront is exactly as planned. (1) Somewhat wondering about how the number sanitization now works. Wondering whether we should perhaps provide a more general solution. Common usage (in some countries) also includes parentheses - like This is another part of what should cover what gets automatically fixed - so perhaps remove any characters in We should then perhaps reject anything that is NOT a phone number. I've tested and the current UI allowed me to add letters to my phone number ... which sounds wrong. However, instead of automatically correcting, this should be rejected. How would a rule to:
Btw, neat trick to use the (2) Nice trick with Thinking whether we should go a step further and require a POST action to actually send a message (requiring an explicit SEND button to be clicked), but this is definitely an improvement and a neat fix. Let's leave this part for later - just me thinking aloud, ignore this one. Otherwise, great work, well done! Cheers, |
| controllers.aaf.vhr.lostpassword.reset.sent.email=Your password reset code has been sent via an email. Please allow at least 5 minutes for codes to be delivered. | ||
| controllers.aaf.vhr.lostpassword.reset.mobile.missing=You must have a mobile number configured to receive an SMS code. Please contact your administrators for more information. | ||
| controllers.aaf.vhr.lostpassword.reset.url.badsecret=An error has occurred while attempting to reset your password. Please try again. | ||
| controllers.aaf.vhr.lostpassword.mobile.invalid=You cannot be sent a reset code because of an issue with your configured mobile number. Please contact an administrator to fix this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| controllers.aaf.vhr.lostpassword.mobile.invalid=You cannot be sent a reset code because of an issue with your configured mobile number. Please contact an administrator to fix this. | |
| controllers.aaf.vhr.lostpassword.mobile.invalid=A reset code could not be sent to you because of an issue with your configured mobile number. Please contact one of our administrator to address this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest commit addresses this.
|
|
||
| checkedNumber = checkedNumber.replace(' ','') | ||
| // Silently remove anything that might be entered by users in a valid-looking phone number. | ||
| checkedNumber = checkedNumber.replaceAll("[ .\\-()]", '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regular expression might be doing something different than what you intended: \\-( might translate to range from \ to (.
The syntax for [] is that a - should come right after the opening [ to be unambigous (not mean a range).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update the expression and test it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, the Regexp implementation is used from Java - so https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html
|
|
||
| checkedNumber = checkedNumber.replace('-','') | ||
| // Valid phone numbers for the app only contain '+' and 0-9. Anything else is probably junk that users will be warned about. | ||
| def newNumber = checkedNumber.replaceAll("[^0-9+]", '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may now be nit-picking, but wondering whether to make diff (and resulting code) smaller by avoiding a new variable and instead of defining newNumber only to be used in one test, you could do:
if (checkedNumber.replaceAll("[^0-9+]", '') != checkedNumber)
(Or possibly finding a shorter way to check if it contains any characters other than 0-9+)
But this is at code-style level - and also OK to leave as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newNumber is used later on to assign to the class variable. I think your suggestion means we'd need an extra call like checkedNumber = checkedNumber.replaceAll... later in the code.
These changes aim to fix the following issues that were found regarding password reset logic:
obtainsubjectis hit.These changes have been tested by myself on a dev instance. I believe they should fix these issues.