use Illuminate\Auth\EloquentUserProvider; use Illuminate\Contracts\Auth\Authenticatable as UserContract; class MyUserProvider extends EloquentUserProvider { protected $model; public function __construct($model) { $this->model = $model; } public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials[‘password‘]; $secret = $user->getAuthPassword(); if (password_verify($plain, $secret)){ return true; }elseif ($this->think_ucenter_md5($plain) === $secret){ $user->password = password_hash($plain, PASSWORD_DEFAULT); $user->save(); return true; } } private function think_ucenter_md5($str) { return md5(sha1($str) . ‘VvKl0QZBE7nao5xtXqGkWrMPchRbHdwmLF361izT‘); } }
时间: 2024-12-17 07:46:52