【发布时间】:2019-12-25 20:44:35
【问题描述】:
我有一个接受登录名和密码,并给出状态或用户 ID 的存储过程。我扩展了 LoginController 来处理它。 这一直有效,直到我输入正确的数据。 执行过程后,我尝试通过 id 授权用户,但这是错误的(并且用户模型不存在)。
public function login(Request $request)
{
$this->validateLogin($request);
if (method_exists($this, 'hasTooManyLoginAttempts') &&
$this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
$result = DB::select(DB::raw("SET NOCOUNT ON {CALL users.Login (@Login =:username, @Password =:password)}"),[
':username' => $request->login,
':password' => $request->password,
]);
switch($result[0]->status){
case '-3':
$message = "Login is banned";
break;
case '-2':
$message = 'Wrong password';
break;
case '-1':
$message = 'You are haven\'t rights';
break;
}
if ($result[0]->status > 0) {
//Auth::loginUsingId($result[0]->status);
return $this->sendLoginResponse($request);
}
$this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request, $message);
}
我接受这个错误:
Symfony\Component\Debug\Exception\FatalThrowableError 类
'\App\Models\User' 未找到
如何将用户数据写入会话并通过 Auth 门面使用?
P.S 我现在存在 this question 但这里没有答案...
【问题讨论】:
-
'\App\Models\User' not found来自哪里? -
@MuhammadDyasYaskur 来自
Auth::loginUsingId($result[0]->status);(?) -
确保您的用户模型存在
标签: sql laravel stored-procedures