mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 23:23:52 +08:00
Add event to allow custom user password validation
This commit is contained in:
parent
a32cb1fede
commit
7b86f412f7
|
@ -15,6 +15,7 @@ use Flarum\Core\Access\Gate;
|
||||||
use Flarum\Core\Support\EventGeneratorTrait;
|
use Flarum\Core\Support\EventGeneratorTrait;
|
||||||
use Flarum\Core\Support\ScopeVisibilityTrait;
|
use Flarum\Core\Support\ScopeVisibilityTrait;
|
||||||
use Flarum\Database\AbstractModel;
|
use Flarum\Database\AbstractModel;
|
||||||
|
use Flarum\Event\CheckUserPassword;
|
||||||
use Flarum\Event\ConfigureUserPreferences;
|
use Flarum\Event\ConfigureUserPreferences;
|
||||||
use Flarum\Event\PostWasDeleted;
|
use Flarum\Event\PostWasDeleted;
|
||||||
use Flarum\Event\PrepareUserGroups;
|
use Flarum\Event\PrepareUserGroups;
|
||||||
|
@ -340,6 +341,12 @@ class User extends AbstractModel
|
||||||
*/
|
*/
|
||||||
public function checkPassword($password)
|
public function checkPassword($password)
|
||||||
{
|
{
|
||||||
|
$valid = static::$dispatcher->until(new CheckUserPassword($this, $password));
|
||||||
|
|
||||||
|
if ($valid !== null) {
|
||||||
|
return $valid;
|
||||||
|
}
|
||||||
|
|
||||||
return static::$hasher->check($password, $this->password);
|
return static::$hasher->check($password, $this->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
framework/core/src/Event/CheckUserPassword.php
Normal file
36
framework/core/src/Event/CheckUserPassword.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user