mercredi 30 mars 2016

Laravel 5 validation issue with reset password form

I am trying reset user password but facing issues with resting my password. I am validating password filed with min:4 validation but when I enter more then 4 character form is not submitting but when I tried with more then 6 it is working.

Any Idea what is wrong in my code.

Here is my HTML:

<div class="reset_password_container">
    <div class="reset_bg">
        <form class="form-horizontal" role="form" method="POST" action="{{ url('/password/reset') }}">
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <input type="hidden" name="token" value="{{ $token }}">

            <div class="find_account_container">
                <div class="find_inner_logo">
                    <h5>{{ trans('messages.reset_password_form.reset_password') }}</h5>
                </div>
                <div class="find_form_dv">
                    <div class="reset_para_dv">
                        <p>{{ trans('messages.reset_password_form.text_1') }}</p>
                        <div class="reset_email_dv">
                            <p>{{ trans('messages.reset_password_form.email') }} <a href="javascript:void(0);">{{ $email }}</a></p>
                        </div>
                    </div>
                    <div class="reset_form_dv">
                        <input type="hidden" class="txt" name="ID" value="{{ $email }}">
                        <input type="password" class="txt" name="password" value="{{ old('password') }}" placeholder="{{ trans('messages.reset_password_form.password') }}">
                        <p class="error"></p>

                        <input type="password" class="txt" name="password_confirmation" value="{{ old('password_confirmation') }}" placeholder="{{ trans('messages.reset_password_form.password_confirmation') }}">
                        <p class="error">
                            @if ($errors->has('password'))
                                {{ $errors->first('password') }}
                            @endif
                        </p>
                    </div>
                </div>
            </div>
            <div class="reset_footer_bg">
                <div class="rest_btn_bg">
                    <button type="submit" class="btn btn-primary">{{ trans('messages.reset_password_form.confirm') }}</button>
                </div>
            </div>
        </form>
    </div>
</div>

PasswordController.php

/**
 * Reset the given user's password.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function postReset(Request $request)
{
    $this->validate($request, [
        'token' => 'required',
        'ID' => 'required|email',
        'password' => 'required|min:6|confirmed',
        'password_confirmation' => 'required|min:6'
    ]);

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

    $response = Password::reset($credentials, function ($user, $password) {
        $this->resetPassword($user, $password);
    });

    switch ($response) {
        case Password::PASSWORD_RESET:
            return redirect($this->redirectPath())->with('status', trans($response));

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



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ZMn5Uz
via IFTTT

Aucun commentaire:

Enregistrer un commentaire