06.05 php saved
stevieboy
Tags add more
simple auth login  
Note
app_controller.php has to be changed
  1. /* SVN FILE: $Id: app_controller.php,v 1.2 2007-11-20 22:56:49 stefan.hoth Exp $ */
  2. /**
  3. * Short description for file.
  4. *
  5. * This file is application-wide controller file. You can put all
  6. * application-wide controller-related methods here.
  7. *
  8. * PHP versions 4 and 5
  9. *
  10. * CakePHP(tm) :  Rapid Development Framework <http://www.cakephp.org/>
  11. * Copyright 2005-2007, Cake Software Foundation, Inc.
  12. *                1785 E. Sahara Avenue, Suite 490-204
  13. *                Las Vegas, Nevada 89104
  14. *
  15. * Licensed under The MIT License
  16. * Redistributions of files must retain the above copyright notice.
  17. *
  18. * @filesource
  19. * @copyright      Copyright 2005-2007, Cake Software Foundation, Inc.
  20. * @link                http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  21. * @package   cake
  22. * @subpackage    cake.app
  23. * @since         CakePHP(tm) v 0.2.9
  24. * @version   $Revision: 1.2 $
  25. * @modifiedby    $LastChangedBy: phpnut $
  26. * @lastmodified    $Date: 2007-11-20 22:56:49 $
  27. * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
  28. */
  29. /**
  30. * Short description for class.
  31. *
  32. * Add your application-wide methods in the class below, your controllers
  33. * will inherit them.
  34. *
  35. * @package  cake
  36. * @subpackage  cake.app
  37. */
  38. class AppController extends Controller {
  39.    
  40.     var $namedArgs = TRUE;
  41.     var $argSeparator = ":";
  42.    
  43.     // check login state for all users using an admin-url
  44.     function beforeFilter(){
  45.    
  46.         $this->getNamedArgs();
  47.        
  48.         if (isset($this->params['admin'])) {
  49.             $this->checkSession();
  50.         }      
  51.     }
  52.    
  53.     //checks login state and
  54.     function checkSession()
  55.     {
  56.         // If the session info hasn't been set...
  57.         if (!$this->Session->check('User'))
  58.         {
  59.             $this->Session->write('returnPath', $_SERVER['REQUEST_URI']);
  60.             // Force the user to login
  61.             $this->redirect('/users/login/');
  62.             exit();
  63.         }
  64.     }
  65. }
Parsed in 0.036 seconds, using GeSHi 1.0.7.14

Modify this Paste