Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Login Laravel登录错误_Login - Fatal编程技术网

Login Laravel登录错误

Login Laravel登录错误,login,Login,我在拉威尔是个新手。我查阅了一个视频教程来设置注册和登录。注册工作完美,但我在登录时遇到了问题。起初它工作得很好,但后来我注意到,我登录哪个用户并不重要,登录的总是同一个用户。但现在,不知从何而来,我甚至无法登录,它抛出了一个错误: 传递给Illumb\Auth\Guard::login()的参数1必须实现接口Illumb\Auth\UserInterface,给定null 我想我知道错误在哪里,但我不认为我的技能能够解决它。 以下是我的UserController代码: public func

我在拉威尔是个新手。我查阅了一个视频教程来设置注册和登录。注册工作完美,但我在登录时遇到了问题。起初它工作得很好,但后来我注意到,我登录哪个用户并不重要,登录的总是同一个用户。但现在,不知从何而来,我甚至无法登录,它抛出了一个错误:

传递给Illumb\Auth\Guard::login()的参数1必须实现接口Illumb\Auth\UserInterface,给定null

我想我知道错误在哪里,但我不认为我的技能能够解决它。 以下是我的UserController代码:

public function login()
{
    return View::make('user.login', array('title'=>'Login'));
}
    public function userlogin()
{
            $validate = Validator::make(Input::all(), array('UserName'=>'required|alpha_num',
                                                            'Password'=>'required'));
            if($validate->fails()){
                return Redirect::back()->withErrors($validate)->withInput(Input::get());                   
            }
            else{
                $checkuser=UserModel::login(input::all());
                if($checkuser[0]){
                    Auth::login(User::find(1));
                    return Redirect::to('users');
                }
                else{
                    return Redirect::back()->withErrors(array('loginerror'=>$checkuser[1]))
                                           ->withInput(Input::get());
                }
            }
}
以下是我的用户模型代码:

    public static function login($values){
    $pickPassword=DB::table('users')->where('name', '=', $values['UserName'])->pluck('password');
    if(!$pickPassword){
        return array(false, "User not found!");
    }
    else{
        $checkPassword=Hash::check($values['Password'],$pickPassword);
        if($checkPassword){return array(true);}
        else {return array(false, "Wrong password");}
    }
}
这是我的用户表:

public function up()
{
        Schema::create('users', function($table)
        {
            // Autoincrement+INT+primary key (Laravel requires)
            $table->increments('id');
            $table->string('name', 100); // VARCHAR 100
            $table->string('email'); // VARCHAR 255
            $table->string('password', 60); // VARCHAR 60
            $table->text('about'); // TEXT 64K
            // Integer + unsigned 4Bytes
            $table->integer('favorite')->unsigned();
            $table->timestamps(); // timestamps (Laravel requires)
            $table->rememberToken();
        });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
        Schema::drop('users');
}
我想问题出在某个地方,用户控制器带有Auth::login,但不是很确定,它在一段时间前工作得很好

Auth::login(User::find(1));
有了这一行,您一直在为第一个用户进行登录

在该区块中:

        else{
            $checkuser=UserModel::login(input::all());
            if($checkuser[0]){
                Auth::login(User::find(1));
                return Redirect::to('users');
您需要将登录表单中给出的参数传递给auth。例如:

if (Auth::attempt(array('email' => $email, 'password' => $password)))
这就是您实际执行的操作,手动登录用户:

旁注:


谢谢,但是Auth::trust如何知道在哪里查找“电子邮件”和“密码”?是否在其他文件中指出?也许我的数据库名称不正确。请查看您的app/config/auth.php文件,在那里您可以命名所使用的模型和可能重复的表