From 23c4caae75ec4e5cdab4b2a497db11d8d6b13cd3 Mon Sep 17 00:00:00 2001 From: efalcy <efalcy@git-test.afi-sa.fr> Date: Wed, 25 Sep 2013 12:43:22 +0000 Subject: [PATCH] clean code --- .../opac/controllers/AuthController.php | 61 ++----------------- 1 file changed, 4 insertions(+), 57 deletions(-) diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index b173290bbad..c797b3d3ea6 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -51,58 +51,12 @@ class AuthController extends ZendAfi_Controller_Action { return $this->_request->getParam('redirect','/opac'); } - protected function processCas() { - $service_cas_server=$this->_request->getParam('service'); - - if (strlen($service_cas_server)<1) - return false; - - if (!Class_Users::getIdentity()) - { - if ($error = $this->_authenticate()) { - $this->_helper->notify($error); - return false; - } - } - - if ($this->isCasDeconnected($service_cas_server)) { - $this->_redirect('/opac'); - return true; - } - - $redirectCas = $this->urlServiceCas($service_cas_server); - if(!$redirectCas == '') { - $this->_redirect($redirectCas); - return true; - } - return false; - } - public function redirect($redirect_url) { $this->_redirect($redirect_url); } - protected function _loginResult($redirect = '', $no_redirection = false){ - $redirect = ($redirect == '') ? $this->_request->getServer('HTTP_REFERER') : $redirect; - $error=''; - if ($this->processCas()) - return; - if (!$this->_request->isPost()) - return; - - if ($error = $this->_authenticate()) { - $this->_helper->notify($error); - - } - - if($no_redirection) - return; - - return $this->_redirect($redirect); - } - public function _authenticate() { // collect the data from the user @@ -301,13 +255,14 @@ class AuthController extends ZendAfi_Controller_Action { abstract class Auth_Strategy_Abstract { + protected $redirect_url=''; protected $disable_redirect=false; - + static public function strategyForController($controller) { if ($controller->isCasRequest() && static::isLogged()) return new Auth_Strategy_Cas_Logged($controller); - + if ($controller->isCasRequest() && !static::isLogged()) return new Auth_Strategy_Cas_NotLogged($controller); @@ -317,6 +272,7 @@ abstract class Auth_Strategy_Abstract { return new Auth_Strategy_NotLogged($controller); } + static protected function isLogged() { return Class_Users::getIdentity(); } @@ -325,7 +281,6 @@ abstract class Auth_Strategy_Abstract { $this->disable_redirect = true; } - public function __construct($controller) { $this->controller=$controller; $this->default_url=$this->controller->getRedirectDefaultUrl(); @@ -335,14 +290,12 @@ abstract class Auth_Strategy_Abstract { return $this->controller->getRequest(); } - public function processLogin() { $this->prepareLogin(); if ($this->getRequest()->isPost()) $this->handlePost(); if ($this->shouldRedirect()) $this->controller->redirect($this->redirect_url); - } public function setDefaultUrl($url) { @@ -372,11 +325,6 @@ abstract class Auth_Strategy_Abstract { class Auth_Strategy_NotLogged extends Auth_Strategy_Abstract{ - public function prepareLogin() { - - } - - public function handlePost() { $this->redirect_url=$this->default_url; if ($error=$this->controller->_authenticate()) { @@ -418,7 +366,6 @@ class Auth_Strategy_Cas_Logged extends Auth_Strategy_Cas_Abstract{ protected function isCasDeconnected() { return stristr($this->controller->getCasServerUrl(),'deconnexion=ok') != FALSE; - } } -- GitLab