【问题标题】:Reset password in laravel 4.1 : Trying to get property of non-object在 laravel 4.1 中重置密码:尝试获取非对象的属性
【发布时间】:2014-08-22 23:15:10
【问题描述】:

我正在我的 laravel 4.1 应用程序中设置密码提醒功能,在我提交重置表单之前,一切似乎都正常工作。当我提交密码重置表单时,我收到此错误:

ErrorException

Trying to get property of non-object

 open: C:\\xampp\WWW\myApp\vendor\laravel\framework\src\Illuminate\Auth\Reminders\DatabaseReminderRepository.php 

手册是我的指南。我已经通过电子邮件成功发送了重置链接,并通过链接获得了表格。但是在提交表单时会出现上述错误。请帮忙。谢谢。

好的。这是我在提醒控制器中负责密码重置的代码。

public function postReset()
{
    $credentials = Input::only(
        'email', 'password', 'password_confirmation', 'token'
    );

    $response = Password::reset($credentials, function($user, $password)
    {

        $user->password = Hash::make($password);

        $user->save();
    });

    switch ($response)
    {
        case Password::INVALID_PASSWORD:
        case Password::INVALID_TOKEN:
        case Password::INVALID_USER:
            return Redirect::back()->with('error', Lang::get($response));

        case Password::PASSWORD_RESET:
            return Redirect::to('/');
    }
  }

注意:它是使用生成的 php art... auth:reminders-controller 根据 laravel doc。 感谢您制作 cmets。

【问题讨论】:

  • 你能给我们更多的信息吗?表格提交后怎么办?你能告诉我们控制器吗?还是形式?信息不足以得出结论
  • 是的,你确实需要展示一些代码,我们无法猜测你的代码是什么样子或者你在做什么。
  • 我正在使用 mongoDb 作为我的数据库。

标签: php laravel laravel-4


【解决方案1】:

我查看了我的 DatabaseReminderRepository.php

我用 dd($reminder) 检查了 $reminder 并给我带来了一个数组,所以我用 $reminder['created_at'];

protected function reminderExpired($reminder) {
// this $reminder->created_at into this $reminder['created_at']
// $createdPlusHour = strtotime($reminder->created_at) + $this->expires;
    $createdPlusHour = strtotime($reminder['created_at']) + $this->expires;
    return $createdPlusHour < $this->getCurrentTime();
}

【讨论】:

    猜你喜欢
    • 2019-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-04
    • 2018-09-26
    相关资源
    最近更新 更多