doulanyan6455 2016-06-07 14:10
浏览 98
已采纳

Laravel - PasswordController :: getToken()不存在

I'm making a password reset in Laravel 5.2 but I have 2 problems.

1) After the user gives in his email, the view from getSent doesn't get show, it just refreshes the email page.

2) When I click the link in the email, I receive this error

Method App\Http\Controllers\Auth\PasswordController::getToken() does not exist

Here's the code of my passwordController, I'm not sure if this is enough to help me, so let me know if you need any other code.

namespace App\Http\Controllers\Auth;

use View;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;

class PasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset requests
    | and uses a simple trait to include this behavior. You're free to
    | explore this trait and override any methods you wish to tweak.
    |
    */

    use ResetsPasswords;

    /**
     * Create a new password controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    public function getSent()
    {
        return View::make('auth.passwordSent');
    }
}

EDIT: Here are my routes

Route::group(['middleware' => ['web', 'csrf']], function () {

    Route::get('/password/reset/email', 'Auth\PasswordController@getEmail');
    Route::post('/password/reset/email', 'Auth\PasswordController@postEmail');

    Route::get('/password/reset/sent', 'Auth\PasswordController@getSent');

    Route::get('/password/reset/{token}', 'Auth\PasswordController@getToken');
    Route::post('/password/reset', 'Auth\PasswordController@postReset');
});
  • 写回答

3条回答 默认 最新

  • duanchen7703 2016-06-07 14:50
    关注

    The first problem is getSent should be getSendResetLinkEmailSuccessResponse because this is the the method in the trait, which you can override:

    public function getSendResetLinkEmailSuccessResponse()
    {
        return View::make('auth.passwordSent');
    }
    

    The second problem is your routes map to methods that don't exist. Instead of getToken, you should be using showResetForm:

    Route::get('/password/reset/{token}', 'Auth\PasswordController@showResetForm');
    

    If you look in Illuminate\Routing\Router.php you will see that the correct password reset routes look like:

    $this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
    $this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
    $this->post('password/reset', 'Auth\PasswordController@reset');
    

    You can implement these in your routes.php simply by:

    Route::auth();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP