0

嗨,我一直在研究 Laravel 框架,但无法让这个身份验证驱动程序工作!返回:

未处理的异常

Message:

Uninitialized string offset: 0
Location:

C:\wamp\www\site\laravel\auth\drivers\eloquent.php on line 39

我有一个登录控制器:

class Login_Controller extends Base_Controller {

    public $restful = true;

    public function post_index()
    {
        $username = Input::get('username');
        $password = Input::get('password');

        if ( Auth::attempt($username, $password) )
        {
            return Redirect::to('home');
        }
        else
        {
            return Redirect::to('login')->with('login_errors', true);
        }

    }

    public function get_index() {

        return View::make('page.login');

    }

}

我有'username' => 'username',

在 auth.php 中为行名

有没有其他人遇到过这个?

问候

菲尔

4

1 回答 1

0

好的,找到了,需要通过数组将凭据传递给尝试方法:

<?php

class Login_Controller extends Base_Controller {

    public $restful = true;

    public function post_index()
    {
        $username = Input::get('username');
        $password = Input::get('password');

        if ( Auth::attempt( array( 'username' => $username, 'password' => $password ) ) )
        {
            return Redirect::to('home');
        }
        else
        {
            return Redirect::to('login')->with('login_errors', true);
        }

    }

    public function get_index() {

        return View::make('page.login');

    }

}
于 2013-01-11T19:03:31.663 回答