-
Notifications
You must be signed in to change notification settings - Fork 650
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
Fix changing email requires new password #2764
Conversation
Same behaviour as on current account page
ping @Kartones can you please review since you did the last changes related to the new account page? Basically, only change password if any password field is set. Although, from a security perspective I wonder I wonder if we really should allow changing email without the user confirming it and/or require current password? cc @xavijam |
cc @rochoa for reporting the issue |
That's why current code flow (at user.rb) doesn't triggers any password change if the old password field comes With your change there would be no error feedback to the user if forgot to set any or two of the three password fields... |
The behaviour you describe sounds great, but that is not how it works I'm afraid. With the change I did it displays the proper messages. I propose you checkout the branch and try yourself then. Without this change you'll get the unwanted behaviour @rochoa reported |
Ok, I now read #2650 , the different title mislead me. I would enforce the 3 fields only if |
If it shows the messages in the ui I'm ok. Backend has tests which is the part that worries me really, other stuff is UI/UX so if works... fine by me :P |
Google+ users have a random password for security reasons. If you need to reason about actual password existence you must user |
@Kartones @juanignaciosl so.. to sum up, what would you have me change here? Or are the changes OK to go as they are now? |
Frontend tests were OK 👍 (details) |
Sorry for drifting out of the main conversation. For me:
|
There's a
|
@juanignaciosl Looking at existing code I could do something similar as where this method is used on organization pages, i.e. disable input field and show message indicating that a password must be set: But does it make sense to show "old password"? What do |
Uhm. It looks like this haven't been brought from Central, where previous user account page belonged. Code suggestion:
And
I think this is all you need, but please let me know if it doesn't work as expected. |
Also fixes #2770 by replacing it with the google-user use-case text
Old password is not required due to google sign-in case (where the user might not have a “old” password yet
Only update last password date if password is fully valid
Finally managed to set up staging to verify this. So with latest modifications to the user model. I've added a test case for the google sign-in to verify password change working. So now the user would see a message why email can't be changed just yet, in addition to knowing that the account is linked with a google account: Once a password is set the email and/or password can be changed as for a normal user: Please review the code again and let me know if there is anything more that needs to be done, or if this is good to go, please, @juanignaciosl @Kartones @xavijam |
+1 looks great! |
@@ -391,11 +391,18 @@ def change_password(old_password, new_password_value, new_password_confirmation_ | |||
|
|||
return unless new_password_value == new_password_confirmation_value && !new_password_value.nil? | |||
|
|||
# Must be set AFTER validations | |||
set_last_password_change_date |
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.
Just a note about this: in production we detected there's a rake task that passed through password change date and thus triggered last_password_change_date
change. That's why it's done in confirmation in Central. 1.- Please check that you can sign up with Google a new user in staging and last_password_change is still nil after a minute or two. 2.- After deploying this to production, check it as well (both environments have different tasks running).
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.
In staging:
irb(main):003:0> u.first.google_sign_in
=> false
irb(main):004:0> u.first.last_password_change_date
=> nil
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.
That would mean it's not working, either you've taken a wrong user, or it's not deployed or something similar...
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, do you mean signup using google sign-in? Or both a normal sign-up and using the google sign-in?
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.
(...the console out above was using the normal sign-up btw)
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.
OK, re-created an user (using google sign-up this time), yields same result:
irb(main):007:0> u.google_sign_in
=> true
irb(main):008:0> u.last_password_change_date
=> nil
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.
Well, google_sign_in
is true
, that's what scared me the most 😄
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.
Ack, will merge & deploy, and reassure that it's the same for production afterwards.
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.
FYI, confirmed
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.
Great, thanks :)
👍 , but take a look at my comment about environments and deployments. |
…e-passwd Fix changing email requires new password
Fixes #2650 (and #2770 while at it)
Same behaviour as on current account page