【问题标题】:How to solve authentication in laravel 4?如何解决 laravel 4 中的身份验证?
【发布时间】:2014-04-04 22:10:15
【问题描述】:

当登录正确的用户名和密码时显示错误

错误异常

参数 1 传递给 Illuminate\Auth\EloquentUserProvider::validateCredentials() 必须是 Illuminate\Auth\UserInterface 的实例,给定的用户实例, 叫进来 E:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Auth\Guard.php 在第 316 行并定义

有人知道问题出在哪里吗?

【问题讨论】:

    标签: php laravel-4


    【解决方案1】:

    当您为用户使用不同的模型时,也可能会出现此错误(例如 :member) 如果是这种情况,您需要使用适当的模型/数据库表更新 app/config/auth.php 中的身份验证模型和身份验证表。

    【讨论】:

      【解决方案2】:

      您的用户模型必须实现 UserInterface 及其方法:

      <?php namespace Illuminate\Auth;
      
      interface UserInterface {
      
          /**
           * Get the unique identifier for the user.
           *
           * @return mixed
           */
          public function getAuthIdentifier();
      
          /**
           * Get the password for the user.
           *
           * @return string
           */
          public function getAuthPassword();
      
      }
      

      所以它必须声明为类似

      use Illuminate\Auth\UserInterface;
      
      class User extends Eloquent implements UserInterface {
      
      }
      

      【讨论】:

      • 谢谢!! @安东尼奥·卡洛斯·里贝罗
      猜你喜欢
      • 2013-09-09
      • 1970-01-01
      • 2013-06-16
      • 1970-01-01
      • 2013-02-27
      • 1970-01-01
      • 2016-02-05
      • 2015-07-22
      • 2013-09-11
      相关资源
      最近更新 更多