问题
I'm building a B2B2C system (i.e. our system provides functionality for other businesses to serve their customers).
For example, a car-garage. Our system would handle multiple garages, each of whom would have their own customers, etc.
As you can imagine, there are three distinct types of users for the system:
- Us (i.e. our admin/sales staff)
- Our customers (i.e. the businesses)
- Their customers (i.e. the end users)
The current authentication system (as far as I can tell) assumes one type of user, whereas we've got three completely distinct independent types, that are stored in their own databases. And it makes no sense to combine them into a single type because the type of data and their permissions, etc, will be completely distinct.
Basically, I need to understand how I can authenticate and log each type in through dedicated entry pages?
I could stretch to making them extend some kind of user table in a polymorphic relationship, but I'd rather avoid that if possible because it just seems like a headache and disaster waiting to happen.
Cheers
回答1:
You could change your auth filter and set sessions / routing accordingly.
Example:
Route::group(array('prefix' => 'admin', 'before' => 'authAdmin'), function() {
// admin routes
Route::controller('foo', 'AdminFooController'); // handles /admin/foo/*
});
Route::group(array('prefix' => 'business', 'before' => 'authBusiness'), function() {
// businesses routes
Route::controller('foo', 'BusinessFooController'); // handles /business/foo/*
});
Route::group(array('before' => 'authEU'), function() {
// end user routes
Route::controller('foo', 'FooController'); // handles /foo/*
});
// Other "non required authentication" routes
来源:https://stackoverflow.com/questions/17531494/multiple-user-types-in-laravel-4