gpt4 book ai didi

php - 身份验证返回 false Laravel 4

转载 作者:行者123 更新时间:2023-11-30 00:56:39 24 4
gpt4 key购买 nike

我正在用 laravel 编写一个简单的身份验证表单。
尝试了两个不同的教程后,它仍然返回 false。
注册工作正常,但我的登录不正常。
这是登录 Controller :

        public function getLogin() {
$this->layout->content = View::make('user.login');
}

public function postSignin() {
if (Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password'))))
{
return Redirect::to('user/dashboard')->with('message', 'You are now logged in!');
}
else
{
return Redirect::to('user/login')
->with('message', 'Your username/password combination was incorrect')
->withInput();
}
}

public function getDashboard() {
$this->layout->content = View::make('user.dashboard');
}

路线:

Route::controller('user', 'UserController');

和 View :

{{ Form::open(array('url'=>'user/signin', 'class'=>'form-signin')) }}
<h2 class="form-signin-heading">Please Login</h2>

{{ Form::text('username', null, array('class'=>'input-block-level', 'placeholder'=>'Username')) }}
{{ Form::password('password', array('class'=>'input-block-level', 'placeholder'=>'Password')) }}

{{ Form::submit('Login', array('class'=>'btn btn-large btn-primary btn-block'))}}
{{ Form::close() }}

最佳答案

在您的表单中,您有一个用户名的输入,但在您的 Controller 中,您有Input::get('email')

你必须像这样编辑你的表单......

{{ Form::text('email', null, array('class'=>'input-block-level', 'placeholder'=>'Username')) }}

...您的 Controller ,就像这样

Auth::attempt(array('email'=>Input::get('username'), 'password'=>Input::get('password')))

关于php - 身份验证返回 false Laravel 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20490540/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com