mbkauthe 1.1.17 → 1.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mbkauthe",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "description": "MBKTechStudio's reusable authentication system for Node.js applications.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -698,7 +698,7 @@
698
698
  {{/if }}
699
699
 
700
700
  <div class="login-links">
701
- <a onclick="fpass()" class="login-link">Forgot Password?</a>
701
+ <a href="https://portal.mbktechstudio.com/forgot-password" class="login-link">Forgot Password?</a>
702
702
  <a href="https://www.mbktechstudio.com/Support" target="_blank" class="login-link">Need Help?</a>
703
703
  </div>
704
704
 
@@ -783,9 +783,9 @@
783
783
  sessionStorage.setItem('sessionId', data.sessionId);
784
784
 
785
785
  if (rememberMe) {
786
- localStorage.setItem('rememberedUsername', username);
786
+ setCookie('rememberedUsername', username, 30); // 30 days
787
787
  } else {
788
- localStorage.removeItem('rememberedUsername');
788
+ deleteCookie('rememberedUsername');
789
789
  }
790
790
 
791
791
  // Redirect to the appropriate page
@@ -818,6 +818,39 @@
818
818
  });
819
819
  });
820
820
 
821
+ // Cookie helper functions for cross-domain functionality
822
+ function setCookie(name, value, days) {
823
+ let expires = "";
824
+ if (days) {
825
+ const date = new Date();
826
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
827
+ expires = "; expires=" + date.toUTCString();
828
+ }
829
+ // Set cookie for the entire domain (works across all subdomains)
830
+ const domain = window.location.hostname.includes('.') ?
831
+ '.' + window.location.hostname.split('.').slice(-2).join('.') :
832
+ window.location.hostname;
833
+ document.cookie = name + "=" + (value || "") + expires + "; path=/; domain=" + domain + "; SameSite=Lax";
834
+ }
835
+
836
+ function getCookie(name) {
837
+ const nameEQ = name + "=";
838
+ const ca = document.cookie.split(';');
839
+ for (let i = 0; i < ca.length; i++) {
840
+ let c = ca[i];
841
+ while (c.charAt(0) === ' ') c = c.substring(1, c.length);
842
+ if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
843
+ }
844
+ return null;
845
+ }
846
+
847
+ function deleteCookie(name) {
848
+ const domain = window.location.hostname.includes('.') ?
849
+ '.' + window.location.hostname.split('.').slice(-2).join('.') :
850
+ window.location.hostname;
851
+ document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=" + domain;
852
+ }
853
+
821
854
  // Check for URL parameters
822
855
  document.addEventListener('DOMContentLoaded', function () {
823
856
  const urlParams = new URLSearchParams(window.location.search);
@@ -850,6 +883,7 @@
850
883
  // Automatically focus the username field
851
884
  usernameInput.focus();
852
885
  });
886
+
853
887
  //Remember me functionality
854
888
  document.addEventListener('DOMContentLoaded', function () {
855
889
  const urlParams = new URLSearchParams(window.location.search);
@@ -857,8 +891,8 @@
857
891
  const passwordFromUrl = urlParams.get('password');
858
892
  const usernameInput = document.getElementById('loginUsername');
859
893
 
860
- // Check for remembered username in localStorage
861
- const rememberedUsername = localStorage.getItem('rememberedUsername');
894
+ // Check for remembered username in cookies
895
+ const rememberedUsername = getCookie('rememberedUsername');
862
896
  if (rememberedUsername) {
863
897
  usernameInput.value = rememberedUsername;
864
898
  document.getElementById('rememberMe').checked = true;