0

my Application has two modules. One for the main application (App) and one for backend administration (Admin). For both I need an user management so I'd like to use ZFCUser. But I want to have different entities and database tables for the backend user (in the Admin module) and frontend user (in the App module). Also I need to set different configurations for the redirect rules.

When I configure e.g. "user_entity_class" in both module config files, it always will use the configuration of the last loaded module.

Has anybody an idea want could be an solution for that? I'm happy about every proposal.

Update: Unfortunately ACL is no solution because both user types are totally different. The entities have different (required) attributes and the workflows like the registration aren't the same.

anho
  • 21
  • 1
  • You may want to think about how you are modeling your application. Why create two entites/tables when you could use one entity/table and add a field that assigns them a role or user type. Less code + more flexibility. – Curtis Kelsey Jul 11 '14 at 14:49
  • There is a standard way of doing this. You should take a look at ACL(access control list) at wikipedia... Hint - role_id. There are a lot of tutorials "how to use ACL in ZF2". – tasmaniski Jul 11 '14 at 15:05
  • thanks for your feedback. The reason why I don't want to solve this issue with ACL is that the entities for backend- and frontend user has nothing common. They have also totally different registration workflows. – anho Jul 13 '14 at 12:28
  • Did you got any solution ? I have same problem. – Rakesh Apr 11 '18 at 11:17

1 Answers1

0

You should only include ZfcUser ONCE. If you want user roles like Admin you should look at ACL/RBAC.

There are modules which integrates with ZfcUser: ACL: https://github.com/bjyoungblood/BjyAuthorize RBAC: https://github.com/ZF-Commons/zfc-rbac

Danielss89
  • 863
  • 1
  • 11
  • 17
  • thanks for your feedback. The reason why I don't want to solve this issue with ACL is that the entities for backend- and frontend user has nothing common. They have also totally different registration workflows – anho Jul 13 '14 at 12:30
  • They have plenty in common. They have the whole "user" part in common. Very stupid to duplicate stuff like id, username, email, password etc. Instead create your base entity which works for both user and admin and then create different entities for the extra stuff and link it. – Danielss89 Jul 13 '14 at 13:21
  • Ok, let us say it is an good idea to use the same entity. Is there an possibilty to set different configuration for options like "login_redirect_route" or "enable_registration"? Because different workflows I have also use an own service for "zfcuser_user_service". Is there any chance to use different services for the two user types? – anho Jul 13 '14 at 13:54