dimanche 29 janvier 2017

Laravel 5 - Authenticate against two tables

Before thinking this is a duplicate, this question is not the same as authenticating against different tables based on a normal user vs. admin user.

I'm somewhat new to Laravel and am having issues trying to authenticate users in the way I need it to be done. I currently have a user table and a companies table. When a user attempts to sign in, I need to check the following:

  1. The user's email and password match (fields in user table)
  2. The user is currently in an active state (field in user table)
  3. The user belongs to an active company (field in companies table)

I have seen numerous examples of authenticating with multiple tables based on whether the user is an admin or not using gaurds, but I determine if a user is an admin with the users table. I just want to check both tables with the criteria I explained above for any user logging in. I would also like to keep this the "Laravel way" as much as possible. Thank you in advance for any help provided.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire