diff --git a/framework/core/src/Core/User.php b/framework/core/src/Core/User.php index 53f5e8013..dfc345568 100755 --- a/framework/core/src/Core/User.php +++ b/framework/core/src/Core/User.php @@ -15,6 +15,7 @@ use Flarum\Core\Access\Gate; use Flarum\Core\Support\EventGeneratorTrait; use Flarum\Core\Support\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; +use Flarum\Event\CheckUserPassword; use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\PostWasDeleted; use Flarum\Event\PrepareUserGroups; @@ -340,6 +341,12 @@ class User extends AbstractModel */ public function checkPassword($password) { + $valid = static::$dispatcher->until(new CheckUserPassword($this, $password)); + + if ($valid !== null) { + return $valid; + } + return static::$hasher->check($password, $this->password); } diff --git a/framework/core/src/Event/CheckUserPassword.php b/framework/core/src/Event/CheckUserPassword.php new file mode 100644 index 000000000..43e50f7c5 --- /dev/null +++ b/framework/core/src/Event/CheckUserPassword.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Event; + +use Flarum\Core\User; + +class CheckUserPassword +{ + /** + * @var User + */ + public $user; + + /** + * @var string + */ + public $password; + + /** + * @param User $user + * @param string $password + */ + public function __construct($user, $password) + { + $this->user = $user; + $this->password = $password; + } +}