diff options
| author | emkael <emkael@tlen.pl> | 2016-05-07 13:24:35 +0200 |
|---|---|---|
| committer | emkael <emkael@tlen.pl> | 2016-05-09 12:35:55 +0200 |
| commit | 640538e18581fb260997b0e84f131eda2b67c98f (patch) | |
| tree | b6010d3f3a06b794511d6103e874f4460b764e39 /app/php/controls/LoginBox.php | |
| parent | e2094c00b4691dcc78b4db8e94a020acdabb1057 (diff) | |
* better handling of login redirects
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(); } } |
