這裏是我的問題:驗證::嘗試不起作用[Laravel]
我有一個表用戶是:
ID的用戶名郵箱密碼
此外,模型的用戶,並當談到註冊時,一切都很好。
現在,當我想在這裏登錄我的觀點:
@layout('main')
@section('content')
@if(Session::has('login_errors'))
<div class='alert alert-error'>Wrong ID</div>
@endif
{{Form::open('user/login', 'POST', array('class' => 'well inline-form'))}}
{{Form::token()}}
{{Form::text('username', Input::old('username'), array('class' => 'input-large', 'placeholder' => 'email'))}}
{{Form::password('password', array('class' => 'input-large', 'placeholder' => 'Mot de passe'))}}
{{Form::submit('Login', array('class'=>'btn btn-primary'))}}
{{Form::close()}}
@endsection
這裏是我在我的控制器做
public function action_login()
{
if(Auth::check()){return Redirect::to('user');}
if(Request::method() == 'POST')
{
$credentials = array('username' => Input::get('username'), 'password' => Input::get('password'));
if(Auth::attempt($credentials))
{
return Redirect::to('user');
}
else
{
return Redirect::to('user/login')->with_input()->with('login_errors', true);
}
}
Section::inject('title', 'Login');
return View::make('user.login');
}
它應該工作,但它不。
錯誤如下:當我點擊登錄按鈕時,我的表單傳遞給我的控制器並被讀取。我知道我的Input :: get('username'),Input :: get('password')是正確的,並在db中註冊。
問題是:即使我的電子郵件/密碼正確,我無法獲得身份驗證,並且我收到我的消息錯誤的ID。我希望我是清楚的...
事情你應該知道:
我沒有在配置改變Auth.php,所以用戶名是電子郵件
我散列密碼,當我與註冊:'密碼」 =>哈希::使(輸入::得到( '密碼'))
編輯和解決方案
好吧,我想通了!
首先:
- 我採用php 5.3.6和Hash 5.3.7需要至少
- 在那之後,我意識到,在我的分貝,密碼是40個字符最多。我覺得自己很蠢
希望它將幫助別人/線程
你可以請你提供你的路線嗎? – bretterer 2013-03-12 02:48:38
我的路線非常簡單:Route :: controller(Controller :: detect()); – 2013-03-12 02:50:14