Redirect to /civicrm when /civicrm/login accessed and already logged in
authorRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Sat, 2 Dec 2023 15:54:38 +0000 (15:54 +0000)
committerRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Sat, 2 Dec 2023 15:54:38 +0000 (15:54 +0000)
ext/standaloneusers/CRM/Standaloneusers/Page/Login.php

index b3a40144e9baf8a3c69f310b69b8e490c4433ae7..d43779d95b336082abb518b8585553aebda358ec 100644 (file)
@@ -5,11 +5,12 @@ use Civi\Standalone\Security;
 class CRM_Standaloneusers_Page_Login extends CRM_Core_Page {
 
   public function run() {
-    // // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
-    // CRM_Utils_System::setTitle(E::ts('Login'));
-    //
-    // // Example: Assign a variable for use in a template
-    // $this->assign('currentTime', date('Y-m-d H:i:s'));
+    Security::singleton()->getLoggedInUfID();
+    if (CRM_Core_Session::singleton()->get('ufID')) {
+      // Already logged in.
+      CRM_Utils_System::redirect('/civicrm');
+    }
+
     $this->assign('logoUrl', E::url('images/civicrm-logo.png'));
     // Remove breadcrumb for login page.
     $this->assign('breadcrumb', NULL);