I have used my own custom login without using auth. Here is my code
public function userLogin(Request $request){
if($request->isMethod('post')){
$data = $request->input();
$this->validate($request, [
'uemail'=> 'required|email',
'user_type'=> 'required',
'user_id' => 'required',
'upassword' => 'required|min:6',
],
[
'uemail.email' => 'Email must be valid',
'uemail.required' => 'Email is required',
'user_type.required' => 'Type is required',
'user_id.required' => 'Name is required',
'upassword.required' => 'Password is required',
'upassword.min' => 'Password must be at least 6 characters',
]);
$user_type = $data['user_type'];
$user_id = $data['user_id'];
$uemail = $data['uemail'];
$upassword = $data['upassword'];
$hashPass = bcrypt($upassword);
DB::enableQueryLog();
$user1 = User::where('type',$user_type)->where('user_id',$user_id)->where('email',$uemail)
->where('status',1)->where('deleted_at',null)->firstOrFail();
$user = DB::table('users')->where('type',$user_type)->where('user_id',$user_id)->where('email',$uemail)
->where('status',1)->where('deleted_at',null);
// $query = DB::getQueryLog();
// $query = end($query);
$isPasswordCorrect = Hash::check($upassword, $user1->password);
if($user == null){
echo "Failed"; die;
}
if($user->exists() && $isPasswordCorrect){
echo "Success"; die;
Session::put('userSession',$user1->email);
Session::put('loginSession',$user_type);
Session::put('idSession',$user1->user_id);
return redirect('/user/dashboard');
} else {
return redirect('/user')->>with('flash_message_error','Invalid Login Credentials..');
}
}
return view('death_notice.user_login');
}
This is my login function. But its not working. When the credentials is right it redirects to dashboard i.e that's correct, but when the credentials is wrong it is not showing error message and says 404 page not found.
I want to have the solution of this problem.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire