可以擴展照亮\身份驗證\ EloquentUserProvider,即:
<?php
namespace App\Services\Auth;
use Illuminate\Auth\EloquentUserProvider as BaseUserProvider;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
class UserProvider extends BaseUserProvider {
/**
* Create a new database user provider.
*
* @param string $model
*
* @return void
*/
public function __construct($model)
{
$this->model = $model;
}
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
*
* @return bool
*/
public function validateCredentials(UserContract $user, array $credentials)
{
$plain = $credentials['password'];
// $matches = some method of matching $plain with $user->getAuthPassword();
return $matches;
}
}
然後在國際奧委會服務提供商像這樣註冊的:
<?php // ...
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
// ...
$this->app['auth']->extend(
'legacy',
function() {
return new \Illuminate\Auth\Guard(
new \App\Services\Auth\UserProvider(
$this->app['config']['auth.model']
),
$this->app['session.store']
);
}
);
// ...
}
然後設置當前的驅動程序遺留在配置/ auth.php。
PS:您可能希望在提供商中包含這些類,
哦否:未來還有另一種安全漏洞。 – zaph
不要在數據庫中使用純文本密碼。 –