0

In a project I am using laravel and for other people's problems I have two tables:

user: id, password, remember_token, person_id

person: id, name, email

The problem is that the data needed to recover the password are in two different tables.

In the ForgotPasswordController.php file

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Http\Request;
use App\User;
use App\Persona;

class ForgotPasswordController extends Controller
{


    use SendsPasswordResetEmails;


    public function sendResetLinkEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email']);


        $response = $this->broker()->sendResetLink(
            $request->only('email')
        );

        switch ($response) {
            case \Password::INVALID_USER:
                return response()->error($response, 422);
                break;

            case \Password::INVALID_PASSWORD:
                return response()->error($response, 422);
                break;

            case \Password::INVALID_TOKEN:
                return response()->error($response, 422);
                break;
            default:
                return response()->success($response, 200);
        }
    }
}

Obviously I get an error that can not find the email column.

SQLSTATE[42703]: Undefined column: 7 ERROR: column "email" does not exist LINE 1: select * from "users" where "email" = $1 limit 1 ^ (SQL: select * from "users" where "email" = email@email.es limit 1)

I finally solved it by helping me with this question. Laravel 5.3 Password Broker Customization

alebupal
  • 118
  • 1
  • 10
  • Your quotes are wrong. Where are you generating this SQL? – Jonnix Jun 04 '19 at 11:43
  • This sql query is generated by laravel using, I do not do it. I have corrected the quotes of the post – alebupal Jun 04 '19 at 12:24
  • Laravel expects the `email` field to be in your `users` table. You're doing something unusual, and will need to customize the built-in functionality to account for that. – ceejayoz Jun 04 '19 at 12:30
  • Yes, that's the question, what do I have to customize to work correctly? – alebupal Jun 04 '19 at 12:48
  • I finally solved it by helping me with this question. https://stackoverflow.com/questions/40532296/laravel-5-3-password-broker-customization – alebupal Jun 05 '19 at 10:01

1 Answers1

0

you aren't using the Eloquent Model Conventions for combining the person with the user.
try replacing the id_person with person_id in your migration (seeders, model, etc.)

  • Sorry, in the message I've put id_person but I really have person_id. The problem is that the email and the password are in different tables ... – alebupal Jun 04 '19 at 14:53
  • I finally solved it by helping me with this question. https://stackoverflow.com/questions/40532296/laravel-5-3-password-broker-customization – alebupal Jun 05 '19 at 10:02