vendredi 11 mars 2016

Laravel 5.1, In password reset form no value in email field

I'm having some issues with password reset process in Laravel 5.1

Step to produce:

  1. Forget password page (Enter password and a reset link will be sent as email)
  2. From email user will click a link similar to http://ift.tt/21Zasa0{longtoken} A form will shown enter new password and retype password

In that form i used same form give here http://ift.tt/1pvrLSf "Sample Password Reset Form"

I just noticed that hidden email field is not populating

<input type="email" name="email" value="{{ old('email') }}">

As i am using laravel's default methods it calls -

public function getReset($token = null)
{
    if (is_null($token)) {
        throw new NotFoundHttpException;
    }

    return view('auth.reset')->with('token', $token);
}

Clearly there is no email variable which is passed to view and it hits postReset after submit -

public function postReset(Request $request)
{
    $this->validate($request, [
        'token' => 'required',
        'email' => 'required|email',
        'password' => 'required|confirmed|min:6',
    ]);

    $credentials = $request->only(
        'email', '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('email'))
                        ->withErrors(['email' => trans($response)]);
    }
}

So main problem is email field isn't populating while i am using the default guide from laravel 5.1 documentation.

Should i pass email parameter like token or i am missing something?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire