summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/php/controls/HeaderMenu.php5
-rw-r--r--app/php/controls/HeaderMenu.tpl2
-rw-r--r--app/php/controls/LoginBox.php22
3 files changed, 23 insertions, 6 deletions
diff --git a/app/php/controls/HeaderMenu.php b/app/php/controls/HeaderMenu.php
index 1e74be3..2488629 100644
--- a/app/php/controls/HeaderMenu.php
+++ b/app/php/controls/HeaderMenu.php
@@ -7,9 +7,10 @@ Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
class HeaderMenu extends TemplateControl {
public function loginUser($sender, $param) {
- $this->Application->getModule('auth')->setReturnUrl($this->Request->RequestUri);
+ $authModule = $this->Application->getModule('auth');
+ $authModule->setReturnUrl($this->Request->RequestUri);
$this->Response->redirect(
- $this->Service->ConstructUrl('Login')
+ $this->Service->ConstructUrl($authModule->LoginPage)
);
}
diff --git a/app/php/controls/HeaderMenu.tpl b/app/php/controls/HeaderMenu.tpl
index b50c4ef..c475a23 100644
--- a/app/php/controls/HeaderMenu.tpl
+++ b/app/php/controls/HeaderMenu.tpl
@@ -1,6 +1,8 @@
<nav role="navigation">
<com:TActiveLinkButton Text="Login" OnCommand="loginUser">
<prop:Visible><%= $this->User->IsGuest %></prop:Visible>
+ <prop:ClientSide.OnFailure>window.location.replace('<%= $this->Service->constructUrl('Login') %>')</prop:ClientSide.OnFailure>
+ <prop:ClientSide.OnException>window.location.replace('<%= $this->Service->constructUrl('Login') %>')</prop:ClientSide.OnException>
</com:TActiveLinkButton>
<com:THyperLink Text="Profile">
<prop:NavigateUrl><%= $this->Service->constructUrl('Profile') %></prop:NavigateUrl>
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();
}
}