Verified Commit e015f808 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3456738 by cmlara, Anybody, andrewbelcher, Berdir, catch: BC break in...

Issue #3456738 by cmlara, Anybody, andrewbelcher, Berdir, catch: BC break in login auth changes from #3444978
parent df700a8d
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ public function login(Request $request) {
        $authenticated = $this->userAuth->authenticateAccount($account, $credentials['pass']) ? $account->id() : FALSE;
      }
      else {
        $authenticated = $this->userAuth->authenticateAccount($credentials['name'], $credentials['pass']);
        $authenticated = $this->userAuth->authenticate($credentials['name'], $credentials['pass']);
      }
      if ($authenticated) {
        $this->userFloodControl->clear('user.http_login', $this->getLoginFloodIdentifier($request, $credentials['name']));
+7 −0
Original line number Diff line number Diff line
@@ -232,6 +232,13 @@ public function validateAuthentication(array &$form, FormStateInterface $form_st
        if ($this->userAuth instanceof UserAuthenticationInterface) {
          $form_state->set('uid', $this->userAuth->authenticateAccount($account, $password) ? $account->id() : FALSE);
        }
        // The userAuth object is decorated by an object that that has not
        // been upgraded to the new UserAuthenticationInterface. Fallback
        // to the authenticate() method.
        else {
          $uid = $this->userAuth->authenticate($form_state->getValue('name'), $password);
          $form_state->set('uid', $uid);
        }
      }
      elseif (!$this->userAuth instanceof UserAuthenticationInterface) {
        $uid = $this->userAuth->authenticate($form_state->getValue('name'), $password);
+28 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\user_auth_decorator_test;

use Drupal\user\UserAuthInterface;

/**
 * Helper to validate UserAuthInterface BC layers are functional.
 */
class UserAuthDecorator implements UserAuthInterface {

  /**
   * Constructs a UserAuthDecorator object.
   *
   * @param \Drupal\user\UserAuthInterface $inner
   *   The inner User.Auth service.
   */
  public function __construct(protected UserAuthInterface $inner) {
  }

  /**
   * {@inheritdoc}
   */
  public function authenticate($username, #[\SensitiveParameter] $password) {
    return $this->inner->authenticate($username, $password);
  }

}
+5 −0
Original line number Diff line number Diff line
name: 'User Auth Service decorated only with UserAuthInterface'
type: module
description: 'Support module for user authentication testing.'
package: Testing
version: VERSION
+6 −0
Original line number Diff line number Diff line
services:
  user_auth_decorator.user.auth:
    class: \Drupal\user_auth_decorator_test\UserAuthDecorator
    decorates: user.auth
    arguments:
      - '@user_auth_decorator.user.auth.inner'
Loading