dt614037527
dt614037527
2017-11-09 15:42

现在重命名Laravel 5.4中的输入密码?

I have a project for Laravel which includes wordpress. They have a common database. When registering the user, the data is entered into the user table when I click forgot the password and enter the email. I receive a link with a token on which it is possible to reset the password, but when I enter the password an error is output that the password is not compatible. How can this be remedied?

That's what I have:

<form method="POST" action="{{ route('password.request') }}">
                {{ csrf_field() }}

                <input type="hidden" name="token" value="{{ $token }}">

                <div class="input-with-icon icon-left">
                    <span class="input-icon text-accent text-left">
                        <i class="fa fa-envelope" aria-hidden="true"></i>
                    </span>
                    <input id="email" type="email" name="user_email" value="{{ old('user_email') }}" required autofocus
                           placeholder="email">
                </div>
                @if ($errors->has('user_email'))
                    <span class="error-block">
                        <strong>{{ $errors->first('user_email') }}</strong>
                    </span>
                @endif
                <div class="spacer-20"></div>
                <div class="input-with-icon icon-left">
                    <span class="input-icon text-accent text-left">
                       <i class="fa fa-lock" aria-hidden="true"></i>
                    </span>
                    <input id="password" type="password" name="user_pass" required placeholder="Password">
                </div>
                @if ($errors->has('user_pass'))
                    <span class="error-block">
                        <strong>{{ $errors->first('user_pass') }}</strong>
                    </span>
                @endif
                <div class="spacer-20"></div>
                <div class="input-with-icon icon-left">
                    <span class="input-icon text-accent text-left">
                       <i class="fa fa-lock" aria-hidden="true"></i>
                    </span>
                    <input id="password-confirm" type="password" name="password_confirmation" required placeholder="Retype Password">
                </div>
                @if ($errors->has('password_confirmation'))
                    <span class="error-block">
                        <strong>{{ $errors->first('password_confirmation') }}</strong>
                    </span>
                @endif
                <div class="spacer-20"></div>
                <div>
                    <button type="submit" class="btn btn-nim btn-nim-clear" style="width: 100%">
                        reset password
                    </button>
                </div>
            </form>

Where do I change the password on user_pass?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongzenglin8292 dongzenglin8292 4年前

    Laravel unfortunately has the password field name hardcoded. The easiest option to work around that would be just to copy the value of user_pass to password in your controller before the default Laravel logic is applied.

    public function reset(Request $request)
    {
      $request->request->set('password', $request->user_pass);
    
      return parent::reset($request);
    }
    
    点赞 评论 复制链接分享