logo       

Re: Check user: msg#00037

php.zend.framework.auth

Subject: Re: Check user

Use Zend_Auth for handling authentication. It has pretty much everything you need.
http://framework.zend.com/manual/en/zend.auth.html

Then, for handling login make a controller plug-in to handle that for you.
http://framework.zend.com/manual/en/zend.controller.plugins.html

Here is the plug-in I've implemented for an app:

<?php
    class Intra_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract {
        public function preDispatch(Zend_Controller_Request_Abstract $request) {
            if ( !($this->getRequest()->getControllerName() === 'auth'
                and $this->getRequest()->getModuleName() === 'default')
                and !Zend_Auth::getInstance()->hasIdentity() )
            {
                $redirectNS = new Zend_Session_Namespace('redirect');
                $redirectNS->fromUrl = $_SERVER['REQUEST_URI'];
                $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
                $redirector->goto('login', 'auth', '');
            }
        }
    }

(All the stuff with $redirectNS is just to be able to redirect the user back to the page he requested after logging in)
Note: Use the latest version of ZF (1.0.2), otherwise you will not be able to use the Redirector helper.

Regards,
Emil Ivanov

On 18/10/2007, Csányi András <sayusi.ando@xxxxxxxxx> wrote:
Hi everybody!

I have a question:
My idea is: every page load i check the user is
logined or not with a isLogin(); method.
When the user is logined the program is running. When
the user is not logined redirect to login form.

I read the documentation but i found nothing about this.

Has anybody some idea about the implementation with Zend_auth
or some documentation (url), or something...?

I searched in the Google without results.

Thanks for help and sorry my english!

Andras

--
-- Csanyi Andras - http://sayusi.hu - Sayusi Ando --
-- "Bízzál Istenben és tartsd szárazon a puskaport!" - Cromwell --




--
My place to share my ideas:
http://vladev.blogspot.com
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise