When logging in, the query fails, because "email" is not on "usuario", it's in "persona"
Unknown column 'email' in 'where clause' (SQL: select * from `usuario` where `email` = admin@localhost limit 1)
It's not a solution to change the database model, as not all "persona" are "usuario", but all "usuario" are "persona".
Tried to set the relationships:
class Persona extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{....}
public function usuario()
{
return $this->hasOne('App\Usuario');
}
//----------------------------------------------------//
class Usuario extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
{....}
public function persona()
{
return $this->hasOne('App\Persona');
}
Both tables have the same key.
But the query doesn't change, I though maybe Laravel could make an "INNER JOIN" somewhere, don't know if Laravel can do that automatically, so I tried to change the query but don't know exactly where is located.
I thought in a solution like this, but it looks too easy, don't know if would be a good way =/
- Get EMAIL and PASSWD from post
- Get the ID, EMAIL and PASSWD from the BD with the SQL
- If [EMAIL and PASSWD match] Auth::loginUsingId(ID); [ELSE] Return with the errors.
As far as I know, the Auth::loginUsingId(ID); acts like a successful Auth::attempt()... but with this solution I'll need to know how to implement later Throttles and the "remember" option separately... all thoughts are welcome :D
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire