首页 > 解决方案 > 覆盖 Laravel 登录以使用 Crypt

问题描述

我正在从以纯文本形式存储密码的旧数据库进行导入。我知道,残酷。虽然我想存储密码,以便他们可以在之后解密并查看它们。(客户要求)。我将密码存储为

$user->password = Crypt::encryptString($oldUser->Password);

如果用户登录,他们将需要使用这个新的 Crypt 来检查。我有这个,但它一直在抛出错误

Auth/LoginController


public function login(Request $request)
     {
        $user =   User::where('username', $request->username)
                     ->where('password',Crypt::encryptString($request->password))
                     ->first();
        Auth::login($user);
        return redirect('/');
     }




Users Model:
class User extends Authenticatable

错误是:

传递给 Illuminate\Auth\SessionGuard::login() 的参数 1 必须实现接口 Illuminate\Contracts\Auth\Authenticatable,给定 null,调用

标签: phplaravellaravel-5eloquent

解决方案


推荐阅读