Created
December 11, 2012 13:33
-
-
Save rufinus/4258599 to your computer and use it in GitHub Desktop.
Redirect if not loged in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return array( | |
| 'controllers' => array( | |
| 'initializers' => array( | |
| function ($instance, $serviceManager) { | |
| if ($instance instanceof NeedLoginAwareInterface) { | |
| $auth = $serviceManager->getServiceLocator()->get('cwdAdmin.auth_service'); | |
| if(!$auth->hasIdentity()) { | |
| //$instance->redirect()->toUrl('/admin/auth/login'); | |
| header('Location: /auth/login'); | |
| exit; | |
| } | |
| } | |
| } | |
| ) | |
| ) | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyController extends Controller implements NeedLoginAwareInterface | |
| { | |
| public function indexAction() | |
| { | |
| // only displayed if we have an identity | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Foo; | |
| interface NeedLoginAwareInterface | |
| { | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment