-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add password confirmation to choose_password #3994
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
Add password confirmation to choose_password #3994
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3994 +/- ##
==========================================
+ Coverage 92.2% 92.22% +0.02%
==========================================
Files 116 116
Lines 8092 8092
==========================================
+ Hits 7461 7463 +2
+ Misses 631 629 -2
Continue to review full report at Codecov.
|
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.
A few nits here and there, @natanrolnik can you validate the JS logic for me please?
views/choose_password
Outdated
|
||
|
||
button:disabled, | ||
button[disabled]{ |
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.
nit space button[disabled] {
views/choose_password
Outdated
@@ -126,6 +131,12 @@ | |||
word-spacing: 0px; | |||
} | |||
|
|||
#password_match_info{ |
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.
nit space #password_match_info{
views/choose_password
Outdated
@@ -156,12 +176,16 @@ | |||
while (pair = tokenize.exec(querystring)) | |||
urlParams[re_space(pair[1])] = re_space(pair[2]); | |||
})(); | |||
|
|||
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.
remove white spaces :)
views/choose_password
Outdated
var id = urlParams['id']; | ||
var base = PARSE_SERVER_URL; | ||
document.getElementById('form').setAttribute('action', base + '/apps/' + id + '/request_password_reset'); | ||
document.getElementById('username').value = urlParams['username']; | ||
document.getElementById('username_label').appendChild(document.createTextNode(urlParams['username'])); | ||
document.getElementById("password").oninput = validatePassword; |
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.
@natanrolnik not sure about that, should we use event listeners instead or is is valid?
views/choose_password
Outdated
function validatePassword(){ | ||
var pass2 = document.getElementById("password").value; | ||
var pass1 = document.getElementById("password_confirm").value; | ||
if(pass1 !== pass2){ |
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.
nit spaces if (pass1 !== pass2) {
views/choose_password
Outdated
var pass2 = document.getElementById("password").value; | ||
var pass1 = document.getElementById("password_confirm").value; | ||
if(pass1 !== pass2){ | ||
if(document.getElementById("password_confirm").value){ |
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.
same
views/choose_password
Outdated
document.getElementById("change_password").disabled = true; | ||
document.getElementById("password_match_info").innerHTML = "Must match the previous entry" | ||
} | ||
}else{ |
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.
same
views/choose_password
Outdated
document.getElementById("change_password").disabled = false; | ||
document.getElementById("password_match_info").innerHTML = "" | ||
} | ||
//empty string means no validation error |
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.
nit alignment
@pungme nice feature, a few nits here and there but otherwise, I'll be happy to get that in! |
Hey @flovilmart thanks for the review! I've changed base on your suggestion. Cheers |
@pungme did you run some tests on that? |
Hey @flovilmart yes i did ran the test on our dev environment. Or do you mean I should write some test on it? |
Just tested on our production, it seems to work fine. let us know if there're anything we should change. Thanks! |
…into pung-updateChoosePasswordTemplate
@pungme this would be awesome if we can get the coverage up to pass. Can you go back over and add one or two tests to account for anything that's untested? |
@montymxb sure! Sorry that i didn’t come back to this pr. I think i’ll have time again this week. :-) |
Whoop time flies! Thanks for getting the coverage up to spec @pungme . @flovilmart JS logic looks good to me 👍 and here's what it looks like once you start typing in your password again, until it matches the existing entry. Just locks the button and displays the text, undoing it once they're both equivalent. As far as setting an inline event callback, that will work just fine. The issue being you can't add more than one without overriding the existing entry for that event. If we want to add more than one listener per event we'll need something that accounts for IE < 9. function addEventListener(elm, event, func) {
if(elm.attachEvent) {
// old IE
return elm.attachEvent('on' + event, func);
} else {
// everything else
return elm.addEventListener(event, func, false);
}
}
// add to some element
addEventListener(document.getElementById('id'), 'input', function() {
// do something on input...
}); |
Oh that’s amazing! |
@montymxb you're afraid it won't fly on ie 9? Should we support it? |
Nope, should be just fine 👍 . It's just adding it like any other attribute of an html element. The only thing being if we ever wanted to go back to this and add another listener on the same event (on the same element) we would have to do the above method or something similar. Considering that I'm willing to give this an approval as is. |
* update choose_password to have the confirmation * update commander * reverted the base * remove some spaces * nits * more nits
Uh oh!
There was an error while loading. Please reload this page.