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