drnx3715 2014-02-09 16:32
浏览 49
已采纳

Laravel 4身份验证:提醒控制器 - 未找到GET重置

I am using Laravel 4's built in password reminder feature in a new application. It seems that the code it's generating and what the docs are saying is either incomplete, inconsistent, or I'm missing a vital point.

So far, I have...

  1. Created Reminder Table
  2. Migrated it
  3. Created Reminder Controller
  4. Tested both get / post for password/remind, successfully.

Where I am stuck is with the reset methods of the controller. The reminder url successfully sends to my email and once I click it, I get a Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException error.

The url that the Password::remind static method sends to my email is http://localhost/application/public/password/reset/3e5e7a5c8562b28909b9948e848c5692dccb4f8a.

My GET / POST reset methods in the reminder controller -

    public function getReset($token = null)
    {
        if (is_null($token)) App::abort(404);

        return View::make('password.reset')->with('token', $token);
    }

    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('/');
        }
    }

My password/reset.blade.php file -

{{ Form::open(array('url' => 'password/reset')) }}
  {{ Form::hidden('token', $token) }}
  {{ Form::email('email', null, array('class'=>'', 'placeholder'=>'Email Address')) }}
  {{ Form::password('password', array('class'=>'', 'placeholder'=>'Password')) }}
  {{ Form::password('password_confirmation', array('class'=>'', 'placeholder'=>'Password Confirmation')) }}

  {{ Form::submit('Reset Password', array('class'=>'')) }}
{{ Form::close() }}

Anyone have any ideas as to where I'm going wrong??

  • 写回答

1条回答 默认 最新

  • dongmacuo1193 2014-02-10 10:13
    关注

    Your most likely missing some routes add these if they don't already exist.

    Route::get('password/reset/{token}', 'RemindersController@getReset');

    It is also likely that you will need the reset post route as well.

    Route::post('password/reset/{token}', 'RemindersController@postReset');

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看