1
我有兩個用於管理員和客戶端的表格,針對每種類型的用戶使用兩種不同的登錄方法。 我已經爲admin使用了try()方法。我正在嘗試爲客戶端創建JWTAuthentication。在這一刻,當我試圖驗證客戶端登錄時,laravel查詢裏面的管理表,而我想要它在客戶端表內查詢。我試圖設置配置來專門研究客戶端模型。但它仍在考慮管理員。Laravel身份驗證模型更改
如何告訴laravel避免在客戶端嘗試登錄時查看管理表?
if($dbPass==$password)
{
//find secret api key and send it to curl
//$this->callTeamworkApi($query->secretApiKey);
//set session
//JWT authenticate
//$credentials = ["email"=>$email,"password"=>$password];
//$credentials = $request->all('email','password');
$credentials =[];
$credentials['email'] = $email;
$credentials['password'] = $request->password;
try{
\Config::set('auth.model', 'Client');
\Config::set('auth.table' , 'clients');
if(! $token = JWTAuth::attempt($credentials))
{
return response()->json([
'response' => 'Some error with user credentials'
]);
}else{
// $request->session()->put('secretApiKey', $query->secretApiKey);
// $request->session()->put('userEmail', $sessionEmail);
// $request->session()->put('userId', $sessionId);
// $request->session()->put('userName', $sessionName);
// $request->session()->put('timeCreated', $timeCreated);
//find user details and put them inside session array
$msg = "Login_checked";
return response()->json(["token"=>compact('token'), "msg"=> $msg]);
}
}catch(JWTExceptions $err){
return response()->json(['response'=>$err]);
}
}else{
$msg = "Password_wrong";
}