From d07a642a2d1ca4b4b5f970036b0747d7b8f9f6de Mon Sep 17 00:00:00 2001 From: Karson Date: Wed, 4 Apr 2018 17:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=90=8E=E6=97=A0=E6=B3=95=E8=BF=94=E5=9B=9E=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E9=A1=B5=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/index/controller/User.php | 23 ++++++++++++++++++----- application/index/view/user/login.html | 1 + application/index/view/user/register.html | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/application/index/controller/User.php b/application/index/controller/User.php index 04ed25bd..73d3f49e 100644 --- a/application/index/controller/User.php +++ b/application/index/controller/User.php @@ -67,7 +67,7 @@ class User extends Frontend */ public function register() { - $url = $this->request->request('url', url('user/index')); + $url = $this->request->request('url'); if ($this->auth->id) $this->success(__('You\'ve logged in, do not login again'), $url); if ($this->request->isPost()) { @@ -116,12 +116,18 @@ class User extends Frontend $uc = new \addons\ucenter\library\client\Client(); $synchtml = $uc->uc_user_synregister($this->auth->id, $password); } - $this->success(__('Sign up successful') . $synchtml, $url); + $this->success(__('Sign up successful') . $synchtml, $url ? $url : url('user/index')); } else { $this->error($this->auth->getError()); } } - Session::set('redirect_url', $url); + //判断来源 + $referer = $this->request->server('HTTP_REFERER'); + if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host())) + && !preg_match("/(user\/login|user\/register)/i", $referer)) { + $url = $referer; + } + $this->view->assign('url', $url); $this->view->assign('title', __('Register')); return $this->view->fetch(); } @@ -131,7 +137,7 @@ class User extends Frontend */ public function login() { - $url = $this->request->request('url', url('user/index')); + $url = $this->request->request('url'); if ($this->auth->id) $this->success(__('You\'ve logged in, do not login again'), $url); if ($this->request->isPost()) { @@ -169,11 +175,18 @@ class User extends Frontend $uc = new \addons\ucenter\library\client\Client(); $synchtml = $uc->uc_user_synlogin($this->auth->id); } - $this->success(__('Logged in successful') . $synchtml, $url); + $this->success(__('Logged in successful') . $synchtml, $url ? $url : url('user/index')); } else { $this->error($this->auth->getError()); } } + //判断来源 + $referer = $this->request->server('HTTP_REFERER'); + if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host())) + && !preg_match("/(user\/login|user\/register)/i", $referer)) { + $url = $referer; + } + $this->view->assign('url', $url); $this->view->assign('title', __('Login')); return $this->view->fetch(); } diff --git a/application/index/view/user/login.html b/application/index/view/user/login.html index 8087150f..b0c5c5ff 100755 --- a/application/index/view/user/login.html +++ b/application/index/view/user/login.html @@ -3,6 +3,7 @@
{:__('Sign in')} {:__('Sign up')}
+
diff --git a/application/index/view/user/register.html b/application/index/view/user/register.html index 34e6180f..ebfac834 100644 --- a/application/index/view/user/register.html +++ b/application/index/view/user/register.html @@ -4,6 +4,7 @@