summaryrefslogtreecommitdiff
path: root/app/php/controls/LoginBox.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-07 13:24:35 +0200
committeremkael <emkael@tlen.pl>2016-05-09 12:35:55 +0200
commit640538e18581fb260997b0e84f131eda2b67c98f (patch)
treeb6010d3f3a06b794511d6103e874f4460b764e39 /app/php/controls/LoginBox.php
parente2094c00b4691dcc78b4db8e94a020acdabb1057 (diff)
* better handling of login redirects
Diffstat (limited to 'app/php/controls/LoginBox.php')
-rw-r--r--app/php/controls/LoginBox.php22
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();
}
}