php - Refactoring a Zend_Auth implementation -


I am working on an existing project that can be entered in two areas. An administrator section and front end

There is currently a login operation in the admin section and the front end has its login action, using admin logs specifically for admin accounts of admin accounts, Using a separate table, the front end is entered.

If the administrator logs in and then attempts to log in at the front end, they are prompted to log in as a front-end user (required because the front end Users take totally different content based on those projects which they are connected and the admin is not connected to a particular project).

Once a front end user, their administrator credentials have gone and they will have to log in again if they try to re-enter the admin section.

I want to do this so that the administrator can be logged in the admin section and log in as a special front end user. This way, to re-login without being able to switch back and forth between the two parts of the site.

What is the best way to handle it within Zend Framework?

So far I have to lose separate login operations and just one (there is no need to be two, right?) And then I will have to deal with the permission of different identities.

At present, logging in to the admin area as a result of the front end user in the admin user. Is this some $ _SESSION credentials being overwritten? Do I need to make any custom $ _SESSION variables to deal with this ZF method?

Obviously I would just do this straight inside $ _SESSION ['front_end'] or $ _SESSION ['admin'] (which I had returned back in the day), how would I do this within the Zend Framework?

Thank you!

The first question, do you really need to do this? Suppose admin users can use all the projects, in this way the typical approach for some, the administrator will have to give a dropdown based on the list of all the projects and allow them to switch between them. Once they are selected, this selection gets accumulated in their session and they can see the data as they are logged in as one of those users, then they can switch between projects on their wishes.

If you really need two logins, then it should definitely be possible. By default Zend_Auth class uses Zend_Auth_Storage_Session to store authentication results in sessions. This class uses the session namespace 'zend_eth' by default (i.e. the data is being stored in $ _ session ['Zend_Auth'] ), so when your front end user successfully enters the admin So its session is overwriting based on the result of the authentic data administrator. So what you want to do, admin login to zend_th_storage (or a cut for each) Nom place) for the use of a different namespace.

In theory, you should be able to do something like this:

  public function loginAction () {$ Auth = Zend_Auth :: getInstance (); if there is some customity for // (//) // Setup storage for custom lottery Check some condition Custom Admin Namespace (can be a string) $ authStorage = NewZend_Auth_Storage_Session ('Yourapp_Admin_Auth');} Else {// Usage Default $ authStorage = New Zend_Auth_Storage_Session ();} $ Auth-> Sets Turn on login to normal ($ authStorage); // [...]}  

So, what is this doing $ _ session ['Yourapp_Admin_Auth'] Zend_Auth is going to admin login and default $ _ session ['Zend_Auth'] for the foreground.


Comments