Kohana的3.3扩展验证模块 [英] Kohana 3.3 expanding the Auth module

查看:217
本文介绍了Kohana的3.3扩展验证模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建设使用验证模块,我需要至少3个账户类型的应用程序:雇主,雇员和客户端。由于这些帐户有不同的属性,功能和关系。(例如:雇主雇员HAS_MANY)我想我需要让他们对3个独立的ORM模型

I'm building an application using the Auth module for which I need at least 3 account types : Employer, Employee and Client. Since these accounts have different properties, functions and relationships (ex: employers has_many employees) I guess I need to have them on 3 separate ORM models.

我想的方法是调整的验证模块来替换相应的子模型(雇主,雇员,客户端)用户模式,在数据库相对应的用户类型。

The method I thought was to tweak the Auth module to replace the 'User' model with the appropriate sub-model (employer, employee, client), corresponding the the user type in the database.

可以这样做,或者是不好的做法?

Can this be done, or is it bad practice?

推荐答案

有关需要延长默认Auth_ORM的 Model_User 类中的每个帐户类型创建不同的模型类,rurposes。

For such rurposes you need to create different Model classes for each account type extending default Auth_ORM's Model_User class.

然后,你需要在你的应用程序来创建新的 Auth_ORM 类扩展 Kohana_Auth_ORM 类/班文件夹中。

Then you need to create new Auth_ORM class extending Kohana_Auth_ORM class in your application/classes folder.

在这个文件中,你需要重写保护_login()方法,因此其 $用户变量指向所需的帐户类型。

In this file you need to rewrite protected _login() method, so its $user variable to point to required account type.

这篇关于Kohana的3.3扩展验证模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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