2016-05-11 103 views
1

我有一个用户验证问题。为登录脚本Laravel 5登录验证问题

enter image description here

现在:我可以创建一个新用户,并使用laravel的Hash::make命令,以便对所有似乎正常工作见下面的数据库记录的密码。我在$input上做了一个转储模,并确认它里面有来自登录表单的发布数据。

代码:

public function CheckLogin() 
{ 
    $input = Request::all(); 

    // create our user data for the authentication 
    $userdata = array(
     'Email'  => $input['email'], 
     'Password' => $input['password'] 
    ); 

    // attempt to do the login 
    if (Auth::attempt($userdata)) { 

// if(Auth::attempt(['Email' => $input['email'], 'Password' =>$input['password'], 'ArchivedOn' => null])){ 

     //return redirect()->intended('devices'); 
      return redirect()->intended('devices'); 

    } else { 

     $err = 'Login Failed Please check credentials and try again.'; 

     return view('welcome', compact('err')); 
    } 

} 

Auth::attempt似乎总是返回false,因为它总是重新定向到与我指定的错误消息的欢迎页面。

我预计我错过了一些明显的东西,但我想我会问一个新的眼睛,因为我看不到问题。

回答

0

你的用户数据应该是: -

$userdata = array(
    'Email'  => $input['email'], 
    'password' => $input['password'] 
); 

注意:您需要在小写字母写密码的P。字。您可以使用电子邮件或用户名更改电子邮件,不管您想要的名称是什么,但密码必须是“密码”

检查this link了解更多详情。

+0

上帝我知道这将是愚蠢的感谢拉维工作 –

+0

不客气:-) –