Tuesday, April 11, 2017

Laravel - sending recovery mail

I'm trying to send a recovery mail using Laravel. I have the following recovery method:

public function recovery(Request $request)
    {
        $validator = Validator::make($request->only('email'), [
            'email' => 'required'
        ]);

        if($validator->fails()) {
            throw new ValidationHttpException($validator->errors()->all());
        }

        $response = Password::sendResetLink($request->only('email'), function (Message $message) {
            $message->subject(Config::get('boilerplate.recovery_email_subject'));
        });

        switch ($response) {
            case Password::RESET_LINK_SENT:
                return $this->response->noContent();
            case Password::INVALID_USER:
                return $this->response->errorNotFound();
        }
    }

I tried to output $request->email and the reset email is the output, but for some reasons I get the following error:

Undefined index: email

at
"/home/pokemoti/public_html/api/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php" on line 74

Any idea what could have gone wrong?



via TheUnreal

Advertisement