laravel背包,如何认证用户

时间:2019-05-02 15:52:56

标签: laravel authentication backpack-for-laravel

我,我已经激活社交名媛和背包,在Facebook登录的第一步之后,我已经在数据库中生成了我的用户。

    $UserModel = BackpackUser::create(['name' => $userProvider->getName(),
                                           'email' => $userProvider->getEmail(),
                                           'provider' => $provider,
                                           'provider_id' => $userProvider->getId(),
                                           'avatar' => $userProvider->getAvatar(),
                                           'avatar_original' => $userProvider->getAvatar(),
                                           'avatar_original' => $userProvider->avatar_original,
                                           "email_verified_at"=>now()->timestamp,//verifica fatta in quanto arriva dai social
                                           'remember_token' => $userProvider->token,
                                           "password" => Hash::make(Str::random(8)),
                                           "user_type" => "player"
                ]);

现在,创建后,我已经通过模型BackpacUser验证了我的新用户

Auth::login($UserModel);

我的检查授权告诉我

Auth :: check(); = true

但是当我尝试访问背包仪表板时,我将重定向到登录页面。

1 个答案:

答案 0 :(得分:0)

已解决,我使用Backpack_auth()-> login($ UserModel);而不是Auth :: login($ UserModel);在我的AuthController中