2

My app needs to support two types of users:

  1. regular users , these are those who are subscribers (restaurants that use my app for managing their business). For these users, I have the out of box authentication (Laravel 5.1) set up. email and password are the fields I authenticate on. I maintain information about such users in my users table.
  2. guests, these are people who visit the restaurants above, register to earn loyalty points, check their score, leave feedback, etc. I maintain information about such users in my guests table. Authentication, in this case, is simple. I just use a mobile_number to authenticate them into the app.

I get that I can implement guest's authentication in a subdomain of my app, with different Controllers and Views.

What I don't get is, how can I use the eloquent database driver with the two distinct models? I see that we specify the model eloquent would be using through config.auth.model. So, I'm assuming that we can only have one single model implementing authentication.

Is, what I trying to achieve, possible without implementing a custom driver?

Code Poet
  • 11,227
  • 19
  • 64
  • 97
  • **Short answer: No.** You need a custom driver for this. But that shouldn't be too hard to implement, as you can easily get inspiration from/or extend the current [`EloquentUserProvider`](https://github.com/laravel/framework/blob/5.2/src/Illuminate/Auth/EloquentUserProvider.php). – Bogdan Feb 12 '16 at 07:52
  • @Bogdan Thanks for the speedy response. I was sure, this would be the short answer :) – Code Poet Feb 12 '16 at 07:59
  • @Bogdan Please write your comments as an answer, so I can give it to you. – Code Poet Feb 12 '16 at 07:59

1 Answers1

0

Short answer: No.

You need a custom driver for this. But that shouldn't be too hard to implement, as you can easily get inspiration from/or extend the current EloquentUserProvider. You can also check out the answer to this other question:

Custom user authentication base on the response of an API call

The context is different than yours, but it may help getting a better grasp on the implementation approach (that is if you haven't done this before).

Community
  • 1
  • 1
Bogdan
  • 43,166
  • 12
  • 128
  • 129