laravel 自定义密码验证方式

继承 EloquentUserProvider

<?php


namespace App\Providers;


use Illuminate\Auth\EloquentUserProvider;
use Illuminate\Contracts\Auth\ Authenticatable as UserContract;

class ApiEloquentUserProvider extends EloquentUserProvider
{
    public function validateCredentials( UserContract $user, array $credentials)
    {

        //这里写自己的验证规则
        $password = $user->system_encrypt($credentials['password'],$user['salt']);
        return $password == $user->getAuthPassword();
    }
}

修改App\Providers\AuthServiceProvider

public function boot()
{
        $this->registerPolicies();

        Auth::provider('api-eloquent', function ( $app, array $config) {
            return new \App\Providers\ApiEloquentUserProvider( $app[ 'hash'], $config[ 'model']);
        });
}

 然后就可以在config/auth.php里直接使用了

‘driver’ => ‘api-eloquent’,

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇