mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-03-07 15:16:40 +08:00
add event EncryptUserPassword
This commit is contained in:
parent
ea1948dc59
commit
e0a59900a3
@ -4,7 +4,7 @@ namespace App\Events;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class CheckUserPassword extends Event
|
||||
class EncryptUserPassword extends Event
|
||||
{
|
||||
public $rawPasswd;
|
||||
|
@ -6,6 +6,7 @@ use DB;
|
||||
use App;
|
||||
use Utils;
|
||||
use Carbon\Carbon;
|
||||
use App\Events\EncryptUserPassword;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class User extends Model
|
||||
@ -69,13 +70,13 @@ class User extends Model
|
||||
*/
|
||||
public function checkPasswd($raw_passwd)
|
||||
{
|
||||
$responses = event(new \App\Events\CheckUserPassword($raw_passwd, $this));
|
||||
$responses = event(new EncryptUserPassword($raw_passwd, $this));
|
||||
|
||||
if (isset($responses[0])) {
|
||||
return (bool) $responses[0];
|
||||
} else {
|
||||
return (app('cipher')->encrypt($raw_passwd, config('secure.salt')) == $this->password);
|
||||
$this->password = $responses[0];
|
||||
}
|
||||
|
||||
return (app('cipher')->encrypt($raw_passwd, config('secure.salt')) == $this->password);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,7 +111,14 @@ class User extends Model
|
||||
*/
|
||||
public function changePasswd($new_passwd)
|
||||
{
|
||||
$this->password = app('cipher')->encrypt($new_passwd, config('secure.salt'));
|
||||
$responses = event(new EncryptUserPassword($new_passwd, $this));
|
||||
|
||||
if (isset($responses[0])) {
|
||||
$this->password = $responses[0];
|
||||
} else {
|
||||
$this->password = app('cipher')->encrypt($new_passwd, config('secure.salt'));
|
||||
}
|
||||
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user