更改记录的用户密码路由始终重定向到Laravel 5中的主页

时间:2015-08-03 16:41:02

标签: php laravel laravel-5 laravel-5.1

我想为已登录用户添加“更改密码”选项。因此,我会覆盖Laravel 5中的默认重置密码选项。

我删除了密码令牌选项而不是电子邮件我使用了full_name

   public function postReset(Request $request)
    {
        $this->validate($request, [

            'full_name' => 'required',
            'password' => 'required|confirmed',
        ]);

        $credentials = $request->only(
            'full_name', 'password', 'password_confirmation'
        );

        $response = $this->passwords->reset($credentials, function($user, $password)
        {
            $user->password = bcrypt($password);

            $user->save();

            $this->auth->login($user);
        });

        switch ($response)
        {
            case PasswordBroker::PASSWORD_RESET:
                return view('auth.reset');

            default:
                return redirect()->back()
                            ->withInput($request->only('full_name'))
                            ->withErrors(['full_name' => trans($response)]);
        }
    }


    /**
     * Display the password reset view for the given token.
     *
     * @param  string  $token
     * @return Response
     */
    public function getReset()
    {


        return view('auth.reset');
    }

Route::post('example/reset', 'Auth\PasswordController@postReset');

当我尝试访问此路线网址时,它始终会重定向到主页。请建议

view - reset.blade.php

<form class="form-horizontal" role="form" method="POST" action="{{ action('Auth\AuthController@update') }}">
                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                        <!-- <input type="hidden" name="token" value="{{ $token }}"> -->

                        <div class="form-group">
                            <label class="col-md-4 control-label">fullname</label>
                            <div class="col-md-6">
                                <input type="text" class="form-control" name="full_name" value="{{ old('full_name') }}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-4 control-label">Password</label>
                            <div class="col-md-6">
                                <input type="password" class="form-control" name="password">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-4 control-label">Confirm Password</label>
                            <div class="col-md-6">
                                <input type="password" class="form-control" name="password_confirmation">
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit" class="btn btn-primary">
                                    Reset Password
                                </button>
                            </div>
                        </div>
                    </form>
                </div>

0 个答案:

没有答案