提问者:小点点

身份验证尝试不起作用,但数据将存储在用户中


我的身份验证::尝试无效。但是我的注册表数据将存储在用户数据库中,并且我还应用了auth::check(),它也不起作用。

这是控制器

public function showLoginform(Request $request){

    $this->validate($request,[
        'email' => 'required',
        'password' => 'required',
    ]);

     $user_data = array(
         'email' => $request->get('email'),
         'password' => $request->get('password')
     );


 if(Auth::attempt($user_data)){
        //return \redirect::to("logged in successfuly");
        echo "yes match";
    } else{
        echo "not match";
       // return "oopps something wrong";
    } 

}

这是我的模型

类用户扩展可验证{使用可通知;

protected $table="users";


protected $fillable = [ 'name', 'email', 'password', 'phonenumber' , 'profession' , 'images' ];


protected $hidden = [
    'password', 'remember_token',
];
}

共1个答案

匿名用户

使用$request-

public function showLoginform(Request $request){

    $this->validate($request,[
        'email' => 'required',
        'password' => 'required',
    ]);

     $user_data = array(
         'email' => $request->input('email'),
         'password' => $request->input('password')
     );


 if(Auth::attempt($user_data)){
        //return \redirect::to("logged in successfuly");
        echo "yes match";
    } else{
        echo "not match";
       // return "oopps something wrong";
    } 

}