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 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测