security - Two tables relation with sfDoctrineGuard user table (symfony) -


Hi,

I have started a part in my web application that allows the user to work Need to be active for it with it I have two tables related: Customers and Enterprise .... First are the users who want to buy a product and the other "user" who want to sell the product.

What is the better way to do that? Relation with user 1table 1: 1? How do I differentiate a user type? Because the user types can only edit some information and enter the enterprise in any other module ...

Thank you very much.

You can use the function on the model.

Example Your Model Customer of user is concerned as such:

  Customer: Relationship: User: Local ID: Foreign ID: ID foreign aliases: customer  

Then you can check that the user is of the customer type (in the controller):

  $ this -> getUser () - & gt; GetGuardUser () - & gt; HasReference ('customer');  

To make this easy, you can add this method to your myUser category:

  is a public function client () {Return $ this- & gt; GetGuardUser () - & gt; HasReference ('customer'); }  

Anyway for Enterprise

Even using two different tables, you can use the hasCredential () method, and this is the easiest way if you only allow Want to check.
If you want to access some features of enterprise and client user, then you can also add both methods.

Update:

Well, assuming that customers and enterprise users have different permissions, I have to go with a user group approach The sfGuard group fits better for the model if you know that a user is in the group customer , you know that the user has a reference to the customer object.

But this means that the right group for a new user to work properly.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -