From 43df2d201c843b59ef4125c68ebdf3c194553f1b Mon Sep 17 00:00:00 2001 From: brunoccast Date: Sun, 2 Jun 2019 13:55:12 +0100 Subject: [PATCH] Extend Action with redirect after login logic, update some actions to use it --- actions/conversation.php | 2 ++ actions/shownotice.php | 2 ++ lib/action.php | 5 +++++ plugins/Directory/actions/groupdirectory.php | 4 ++-- plugins/Directory/actions/userdirectory.php | 4 ++-- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/actions/conversation.php b/actions/conversation.php index 8fcf3f47d6..e69c9c35ce 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -47,6 +47,8 @@ if (!defined('GNUSOCIAL')) { */ class ConversationAction extends ManagedAction { + protected $redirectAfterLogin = true; + public $conv = null; public $page = null; public $notices = null; diff --git a/actions/shownotice.php b/actions/shownotice.php index ea43780e16..a2fa01d21a 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -44,6 +44,8 @@ require_once INSTALLDIR.'/lib/noticelist.php'; */ class ShownoticeAction extends ManagedAction { + protected $redirectAfterLogin = true; + /** * Notice object to show */ diff --git a/lib/action.php b/lib/action.php index 32b49e4e11..9cde0d7637 100644 --- a/lib/action.php +++ b/lib/action.php @@ -60,6 +60,7 @@ class Action extends HTMLOutputter // lawsuit protected $ajax = false; protected $menus = true; protected $needLogin = false; + protected $redirectAfterLogin = false; protected $needPost = false; // implies canPost if true protected $canPost = false; // can this action handle POST method? @@ -248,6 +249,10 @@ class Action extends HTMLOutputter // lawsuit if ($this->needLogin) { $this->checkLogin(); // if not logged in, this redirs/excepts } + + if ($this->redirectAfterLogin) { + common_set_returnto($this->selfUrl()); + } $this->updateScopedProfile(); diff --git a/plugins/Directory/actions/groupdirectory.php b/plugins/Directory/actions/groupdirectory.php index ecedfebd0d..83742f8c74 100644 --- a/plugins/Directory/actions/groupdirectory.php +++ b/plugins/Directory/actions/groupdirectory.php @@ -43,6 +43,8 @@ if (!defined('GNUSOCIAL')) { */ class GroupdirectoryAction extends ManagedAction { + protected $redirectAfterLogin = true; + /** * The page we're on * @@ -143,8 +145,6 @@ class GroupdirectoryAction extends ManagedAction $this->reverse = $this->boolean('reverse'); $this->q = $this->trimmed('q'); $this->sort = $this->arg('sort', 'nickname'); - - common_set_returnto($this->selfUrl()); } /** diff --git a/plugins/Directory/actions/userdirectory.php b/plugins/Directory/actions/userdirectory.php index 51b84ed4c1..7f6a899f1f 100644 --- a/plugins/Directory/actions/userdirectory.php +++ b/plugins/Directory/actions/userdirectory.php @@ -42,6 +42,8 @@ if (!defined('GNUSOCIAL')) { */ class UserdirectoryAction extends ManagedAction { + protected $redirectAfterLogin = true; + /** * The page we're on * @@ -140,8 +142,6 @@ class UserdirectoryAction extends ManagedAction $this->reverse = $this->boolean('reverse'); $this->q = $this->trimmed('q'); $this->sort = $this->arg('sort', 'nickname'); - - common_set_returnto($this->selfUrl()); } /** -- 2.39.5