Hello.
The path creates a link ("Have you forgotten your password?") to display if the user wasn't able to login via the Login checkout pane.

Comments

daria.a created an issue. See original summary.

daria.a’s picture

mglaman’s picture

Status: Needs review » Needs work
  1. +++ b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php
    @@ -244,7 +244,10 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container
    +      $user_input = $form_state->getUserInput();
    
    @@ -265,7 +268,10 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container
    +      $user_input = $form_state->getUserInput();
    

    You have $values available, use that. I just looked at \Drupal\user\Form\UserLoginForm::validateFinal, which seems to be what you referenced. Can you provide some inline comments referring to there, and that's why we check input v. the values?

  2. +++ b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php
    @@ -244,7 +244,10 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container
    +      $query = isset($user_input['name']) ? array('name' => $user_input['name']) : array();
    +      $form_state->setErrorByName('name', $this->t('Unrecognized username or password. <a href=":password">Have you forgotten your password?</a>', array(':password' => \Drupal::url('user.pass', [], array('query' => $query)))));
    
    @@ -265,7 +268,10 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container
    +      $query = isset($user_input['name']) ? array('name' => $user_input['name']) : array();
    +      $form_state->setErrorByName('name', $this->t('Unrecognized username or password. <a href=":password">Have you forgotten your password?</a>', array(':password' => \Drupal::url('user.pass', [], array('query' => $query)))));
    

    Long array usage. Convert to []

    Use Url::fromRoute

daria.a’s picture

Hello Matt,
and thank you for your answer; I've changed the patch based on it.
Talking about point 1 from you post, now I think we don't really need to use getUserInput() in this case. The method \Drupal\user\Form\UserLoginForm::validateFinal is being used in the last step of validation process and the data of the form could be altered during the previous steps (as it's written in the comment for the method). But in our case we don't use several validation methods and so now I've choose to use the $values for getting username.

Hope I was able to got your points right, if not, I would be really glad to hear additional recommendations about this patch improvements.

daria.a’s picture

Status: Needs work » Needs review

  • bojanz committed 283dd88 on 8.x-2.x authored by daria.a
    Issue #2772253 by daria.a: Checkout pane Login. Link "forgot password"...
bojanz’s picture

Status: Needs review » Fixed

Tweaked based on GitHub comments, and committed. Thanks!

Status: Fixed » Closed (fixed)

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