If the password is expired and the user tries to reset his password, the password will be reset successfully but the flag for expired password will not be removed due to undefined variables in the code.

$uid = $form_state->getValue('uid');

$form_state->getValue('uid'); is undefined since the uid in Drupal 8 isn't part of the form state object.

This should be replaced by:

// get the uid from user object.
$user = $form_state->getFormObject()->getEntity();
$uid = $user->id();
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mqanneh created an issue. See original summary.

mqanneh’s picture

mqanneh’s picture

Ahmad Abbad’s picture

Status: Needs review » Reviewed & tested by the community

This patch #3 worked for me.

nerdstein’s picture

Status: Reviewed & tested by the community » Fixed

This looks good, thank you. Merging.

  • nerdstein committed cf18340 on 8.x-3.x authored by mqanneh
    Issue #2867089 by mqanneh: Code logic will never reset password expiry
    
mqanneh’s picture

nikunjkotecha’s picture

FileSize
749 bytes

We are using this at different places, for instance with https://www.drupal.org/project/change_pwd_page.

Recent change here broke as ChangePasswordForm in the contrib module doesn't implement EntityForm.

I suggest we use more generic way of getting current user, that is from route params. Added patch for the same.

nikunjkotecha’s picture

FileSize
1017 bytes

Fixed issue related to registration page where we don't have user in route params.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.