Multiple user types in Laravel 4

雨燕双飞 提交于 2019-12-11 05:42:50

问题


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:

  1. Us (i.e. our admin/sales staff)
  2. Our customers (i.e. the businesses)
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!