standalone: fix test, cleanup unnecessary javascript
authorRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Tue, 5 Dec 2023 14:15:19 +0000 (14:15 +0000)
committerRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Tue, 5 Dec 2023 14:22:42 +0000 (14:22 +0000)
ext/standaloneusers/CRM/Standaloneusers/Page/Login.php
ext/standaloneusers/templates/CRM/Standaloneusers/Page/Login.tpl

index 6fec79f81772b44242d02dc3d573b58da5454ba2..d9017529dc5bd94e0ea85a790a6c3665cb7be045 100644 (file)
@@ -17,6 +17,9 @@ class CRM_Standaloneusers_Page_Login extends CRM_Core_Page {
     // Remove breadcrumb for login page.
     $this->assign('breadcrumb', NULL);
 
+    $this->assign('anonAccessDenied', isset($_GET['anonAccessDenied']));
+    $this->assign('justLoggedOut', isset($_GET['justLoggedOut']));
+
     parent::run();
   }
 
index b6a3dcfa86063838e6e0b35a45be88cdc1c6e85d..573bc4a7769053ca33ad9c2ef2532d3257111393 100644 (file)
@@ -2,7 +2,13 @@
     <div class="message info" style="display:none;" id="loggedOutNotice">{ts}You have been logged out.{/ts}</div>
     <div class="message warning" style="display:none;" id="anonAccessDenied">{ts}You may need to login to access that.{/ts}</div>
     <form>
-      <div>
+      {if $justLoggedOut}
+      <div class="help message info" >{ts}You have been logged out.{/ts}</div>
+      {/if}
+      {if $anonAccessDenied}
+      <div class="help message warning" >{ts}You do not have permission to access that, you may need to login.{/ts}</div>
+      {/if}
+      <div class="input-wrapper">
         <label for="usernameInput" name=username class="form-label">Username</label>
         <input type="text" class="form-control" id="usernameInput" >
       </div>
@@ -12,8 +18,8 @@
       </div>
       <div id="error" style="display:none;" class="form-alert">Your username and password do not match</div>
       <div class="flex">
-      <a href="{$forgottenPasswordURL}">Forgotten password?</a>
-      <button id="loginSubmit" type="submit" class="btn btn-secondary crm-button">Submit</button>
+        <a href="{$forgottenPasswordURL}">Forgotten password?</a>
+        <button id="loginSubmit" type="submit" class="btn btn-secondary crm-button">Submit</button>
       </div>
     </form>
   {include file='CRM/Standaloneusers/Page/_contentFoot.tpl'}
@@ -23,17 +29,8 @@ document.addEventListener('DOMContentLoaded', () => {
 
   const submitBtn = document.getElementById('loginSubmit'),
         username = document.getElementById('usernameInput'),
-        password = document.getElementById('passwordInput'),
-        loggedOutNotice = document.getElementById('loggedOutNotice');
+        password = document.getElementById('passwordInput');
 
-  // Special messages.
-  if (window.location.search === '?justLoggedOut') {
-    loggedOutNotice.style.display = '';
-    console.log("successful logout");
-  }
-  else if (window.location.search === '?anonAccessDenied') {
-    anonAccessDenied.style.display = '';
-  }
 
   submitBtn.addEventListener('click', async e => {
     e.preventDefault();