这里是我的问题:验证::尝试不起作用[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