diff options
Diffstat (limited to 'app/php/controls/LoginBox.php')
-rw-r--r-- | app/php/controls/LoginBox.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/app/php/controls/LoginBox.php b/app/php/controls/LoginBox.php index a22750c..1136a79 100644 --- a/app/php/controls/LoginBox.php +++ b/app/php/controls/LoginBox.php @@ -4,12 +4,26 @@ Prado::using('Application.web.TemplateControl'); class LoginBox extends TemplateControl { + public function onInit($param) { + parent::onInit($param); + if (!$this->Page->IsPostBack && !$this->User->IsGuest) { + $this->_afterLoginRedirect(); + } + } + + private function _afterLoginRedirect() { + $authModule = $this->Application->getModule('auth'); + $redirUrl = $authModule->ReturnUrl; + if (!$redirUrl + || $redirUrl == $this->Service->constructUrl($authModule->LoginPage)) { + $redirUrl = $this->Service->constructUrl(NULL); + } + $this->Response->redirect($redirUrl); + } + public function loginUser($sender, $param) { if ($this->Page->IsValid) { - $this->Response->redirect( - $this->Application->getModule('auth')->ReturnUrl - ?: $this->Service->constructUrl(NULL) - ); + $this->_afterLoginRedirect(); } } |