尝试登录laravel时出现令牌问题


Token issue when attempting to login laravel

所以我有一个登录功能张贴在下面,工作很好,大多数时候没有问题。但是在主页上,不管什么原因,如果你尝试登录它不会验证你的身份,并将url更改为以下

http://localhost/?_token=Jh36AX6sx0qhzOniPoMSn3pROCAVombCn4xKzoJm&email=admin%40admin.com&password=testpass

这对我来说没有意义,它抛出一些奇怪的错误,并以纯文本显示电子邮件和密码。有人知道是怎么回事吗?我在任何其他页面上使用完全相同的功能,它工作得很好,但不是主页。我唯一一次看到url做类似的事情是在设置和做密码重置的东西。什么好主意吗?

public function doLogin()
    {
        // validate the info, create rules for the inputs
        $rules = array(
            'email1'    => 'required|email', // make sure the email is an actual email
            'password1' => 'required|alphaNum|min:3' // password can only be alphanumeric and has to be greater than 3 characters
        );
        // run the validation rules on the inputs from the form
        $validator = Validator::make(Input::all(), $rules);
        // if the validator fails, redirect back to the form
        if ($validator->fails()) 
        {
            return Redirect::to('login')->withErrors($validator)->withInput(Input::except('password1')); // send back the input (not the password) so that we can repopulate the form
        } 
        else 
        {
            // create our user data for the authentication
            $userdata = array(
                'email'     => Input::get('email1'),
                'password'  => Input::get('password1')
            );
            // attempt to do the login
            if (Auth::attempt($userdata)) 
            {
                return Redirect::to('profile');
            } 
            else 
            {       
                $this->layout->content = View::make('login')->with('p', 'Incorrect Login Information');
            }
        }
    }

根据请求,这是调用函数的表单,它使用POST

{{ Form::open(array('url' => 'login', 'class' => 'form form-horizontal' ,'method' => 'post')) }}
{{ Form::text('email1', Input::old('email1'), array('class'=>'form-control','placeholder' => 'Email Address')) }}
{{ Form::password('password1', array('class'=>'form-control','placeholder' => 'Password')) }}
  <button type="submit" class="btn btn-primary form-control">Login</button><br><br>
{{ HTML::link('login/fb', 'Sign-in with Facebook',array('class' => 'btn btn-primary form-control facebook')) }}
{{ HTML::link('password/remind', 'Forgot Password?') }}
{{ Form::close() }}

看起来您的表单正在使用GET而不是POST。我建议张贴你的表单代码来验证这一点。当您切换到POST时,请确保您的路由设置为将其作为POST请求来处理。