Laravel 无法验证用户身份

2024-02-24

        $userdata = array(
            'email' => Input::get('email'),
            'password'  => Input::get('password')
            );



        if (Auth::attempt($userdata)) {

            echo 'SUCCESS!';

        } else {        

            return Redirect::to('login');

        }

当我从浏览器运行应用程序时,我收到此错误:

Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Auth\UserInterface, instance of User given, called in /home/srtpl17/Sites/yatin.sr/vendor/laravel/framework/src/Illuminate/Auth/Guard.php on line 316 and defined

我做错了什么?


从你的错误看来,你的 User 模型没有实现 UserInterface (Laravel 附带的默认 User Model 可以正确执行此操作,所以我猜你做了一个自定义的)

http://github.com/laravel/laravel/blob/master/app/models/User.php http://github.com/laravel/laravel/blob/master/app/models/User.php

确保用户模型如下所示:

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {


/**
 * Get the unique identifier for the user.
 *
 * @return mixed
 */
public function getAuthIdentifier()
{
    return $this->getKey();
}

/**
 * Get the password for the user.
 *
 * @return string
 */
public function getAuthPassword()
{
    return $this->password;
}

/**
 * Get the e-mail address where password reminders are sent.
 *
 * @return string
 */
public function getReminderEmail()
{
    return $this->email;
}

// Add your other methods here

}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Laravel 无法验证用户身份 的相关文章

  • Laravel 外键下拉列表

    我有 2 张桌子 客户 id 全名 公司 ID 公司 id 公司名称 我已经创建了两个表之间的关系 并且工作正常 因为我可以在客户视图中显示公司名称 如下所示 customer gt company gt company name 我现在与
  • 构建网站翻译文件

    我在建立网站时多次遇到这个问题 我将以使用 PHP 和 Laravel 为例进行解释 但这个问题在多个平台中都很常见 这已经在几个问题中得到了解决 post1 https stackoverflow com questions 317854
  • Laravel:BadMethodCallException 方法 [find] 不存在

    当尝试使用模型对象 User 从数据库中提取一些值时 出现以下错误 BadMethodCallException Method find does not exist 这是我的文件 模范用户
  • Laravel 快速入门指南路线不起作用

    好吧 我是 Laravel 新手 所以直接查看文档开始 文档中存在大量漏洞 因此需要花费大量精力和谷歌搜索来填补空白才能完成 Laravel 设置 我现在已经设置完毕并继续执行快速入门指南中的下一步 我创建了我的路线 Route get u
  • AWS lambda 基本身份验证,无需自定义授权者

    我在为用 Node js 编写的 AWS lambda 函数设置基本身份验证时遇到问题 问题 AWS lambda 函数是附加服务的代理 该函数仅转发整个请求并向用户提供整个响应 这就是为什么我需要强制使用Authentication标题
  • authenticationEntryPoint 不适用于提交凭据的 Permit() http 方法

    Override protected void configure HttpSecurity httpSecurity throws Exception formatter off httpSecurity csrf disable aut
  • Vagrant - Homestead 设置多个站点

    我已经使用 homestead yaml 映射了文件夹等 ip 192 168 10 10 folders map Users User Desktop folder Homestead First to home vagrant Firs
  • 从关系中合并 Laravel 中的集合

    假设我有 3 张桌子 Images Subject Style 关系是多对多 图像 主题 和多对多 图像 样式 现在我想做一些类似的事情 result subjectResult gt images gt merge styleResult
  • Laravel 保存/更新多对多关系

    谁能帮助我如何保存多对多关系 我有任务 用户可以有很多任务 任务可以有很多用户 多对多 我想要实现的是更新表格管理员可以将多个用户分配给特定任务 这是通过 html 多选输入完成的 name taskParticipants 这里的问题是
  • Laravel 中的高级 whereNotNull 语句

    在 Laravel 4 中可以执行以下操作吗 DB table myTable gt select DB raw columnNames gt whereNotNull function query use columns foreach
  • Laravel 4 Blade @include 变量

    我试图做include使用 Laravel Blade 但问题是它无法传递变量 这是我的示例代码 file include blade php
  • HTTP 基本身份验证 + 访问令牌?

    我正在开发一个 REST API 计划将其与 Web 和 IOS 应用程序一起使用 我打算让这个 API 在一段时间内保持私有 私有意味着我只希望我的 Web 应用程序和 ios 应用程序访问该 API 我已经阅读了许多不同的身份验证方法
  • 将资源文件链接到 Laravel4 中的视图

    您好 我是新手 正在学习 laravel 4 创建应用程序 我正在尝试使用 laravel Blade 将 twitter bootstrap3 文件链接到视图 我安装了一个新的 laravel 应用程序文件夹 为了从 url 路径中删除
  • Laravel 4 删除默认 getIndex 控制器函数上的 /index

    是否可以删除默认 getIndex Restful 控制器功能上的 index 控制器定义的路线 Route controller registration RegisterController array getIndex gt getR
  • 使用 HTTP-Basic 身份验证发出 HTTP GET 请求

    我需要为我正在开发的 Flash Player 项目构建一个代理 我只需要使用 HTTP Basic 身份验证向另一个 URL 发出 HTTP GET 请求 并提供来自 PHP 的响应 就好像 PHP 文件是原始源一样 我怎样才能做到这一点
  • 在 nginx 后面使用 GitLab 启用 basic_auth?

    我已经成功安装了 GitLab 来管理私有存储库 这真是太棒了 我遇到的问题是默认情况下 当任何人访问我的子域时都会显示 Gitlab 登录信息 我想在用户获得 GitLab 登录屏幕之前使用 basic auth 层保护整个区域 不幸的是
  • ajax 请求中的 laravel TokenMismatchException

    我正在使用资源组并使用此过滤器来解析TokenMismatchException问题 Route filter csrf function route request if strtoupper request gt getMethod G
  • Laravel 4,如何在 Route::controller() 上应用过滤器

    我知道我能做到 Route get foo bar array before gt filter uses gt Controller bar 应用路由一些过滤器 我也知道 Route group 方法 无论如何 如果我想以这种方式定义一个
  • Laravel 自定义授权

    我在这里进行登录验证 LoginData Input except array token if Auth attempt LoginData return success 我的表不同 所以这里我更改表名称auth php table gt
  • updateExistingPivot() 不起作用

    我正在尝试像这样更新数据透视表 public function updatePermission id permissionId permissionValue Input get value user User find id perms

随机推荐