在Laravel 4多个用户类型 [英] Multiple user types in Laravel 4

查看:100
本文介绍了在Laravel 4多个用户类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个B2B2C系统(即我们的系统提供的功能为其他企业服务于他们的客户)。

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. 我们(即我们的管理/销售人员)

  2. 我们的客户(即企业)

  3. 他们的客户(即最终用户)

目前的认证系统(只要我可以告诉)假定一种类型的用户,而我们有三个完全不同类型独立,存储在自己的数据库。而且它是没有意义将它们合并为一个单一的类型,因为数据和他们的权限等的类型,将完全不同。

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.

干杯

推荐答案

您可以改变你的权威性过滤器和设置会话/路由相应。

You could change your auth filter and set sessions / routing accordingly.

例如:

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

这篇关于在Laravel 4多个用户类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆