Art.Kl.
Art.Kl.

Reputation: 11

Now to rename input password in 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?

Upvotes: 1

Views: 96

Answers (1)

jedrzej.kurylo
jedrzej.kurylo

Reputation: 40909

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);
}

Upvotes: 1

Related Questions