mbkauthe 4.1.1 → 4.1.2

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.
@@ -6,18 +6,13 @@ import { clearSessionCookies, cachedCookieOptions, readAccountListFromCookie } f
6
6
  async function validateSession(req, res, next) {
7
7
  if (!req.session.user) {
8
8
  console.log("[mbkauthe] User not authenticated");
9
- const remembered = readAccountListFromCookie(req) || [];
10
- const hasRemembered = remembered.some(acct => acct && typeof acct.sessionId === 'string' && acct.sessionId.length > 0);
11
- const pageTarget = hasRemembered ? '/mbkauthe/accounts' : `/mbkauthe/login?redirect=${encodeURIComponent(req.originalUrl)}`;
12
- const message = hasRemembered
13
- ? "Another saved account is available. Open the switch page to continue."
14
- : "You Are Not Logged In. Please Log In To Continue.";
15
- return renderError(res, req, {
9
+ console.log("[mbkauthe]: ", req.session.user);
10
+ return renderError(res, {
16
11
  code: 401,
17
12
  error: "Not Logged In",
18
- message,
19
- pagename: hasRemembered ? "Switch Account" : "Login",
20
- page: pageTarget,
13
+ message: "You Are Not Logged In. Please Log In To Continue.",
14
+ pagename: "Login",
15
+ page: `/mbkauthe/login?redirect=${encodeURIComponent(req.originalUrl)}`,
21
16
  });
22
17
  }
23
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mbkauthe",
3
- "version": "4.1.1",
3
+ "version": "4.1.2",
4
4
  "description": "MBKTech's reusable authentication system for Node.js applications.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -29,13 +29,13 @@
29
29
  <i class="fab fa-github"></i>
30
30
  <span>Continue with GitHub</span>
31
31
  </a>
32
- {{/if }}
32
+ {{/if}}
33
33
  {{#if googleLoginEnabled }}
34
34
  <a type="button" id="googleLoginBtn" class="btn-social btn-google-side">
35
35
  <i class="fab fa-google"></i>
36
36
  <span>Continue with Google</span>
37
37
  </a>
38
- {{/if }}
38
+ {{/if}}
39
39
  <a href="/mbkauthe/accounts" id="switchacc" class="btn-social btn-switch-side">
40
40
  <i class="fa fa-user-group"></i>
41
41
  <span>Switch Account</span>
@@ -68,7 +68,7 @@
68
68
  <a class="terms-link" href="/mbkauthe/accounts">switch account</a>.
69
69
  </div>
70
70
  </div>
71
- {{/if }}
71
+ {{/if}}
72
72
  <input type="hidden" name="_csrf" value="{{csrfToken}}">
73
73
  <div class="form-group">
74
74
  <input id="loginUsername" class="form-input" type="text" name="username" placeholder=" "
@@ -312,7 +312,7 @@
312
312
  }
313
313
  });
314
314
 
315
- { { #if githubLoginEnabled } }
315
+ {{#if githubLoginEnabled }}
316
316
 
317
317
  // GitHub login: Navigate directly to GitHub OAuth flow
318
318
  async function startGithubLogin() {
@@ -328,9 +328,9 @@
328
328
  const mobileGithubBtn = document.querySelector('.mobile-github-btn');
329
329
  if (githubBtn) githubBtn.addEventListener('click', startGithubLogin);
330
330
  if (mobileGithubBtn) mobileGithubBtn.addEventListener('click', startGithubLogin);
331
- { {/if } }
331
+ {{/if}}
332
332
 
333
- { { #if googleLoginEnabled } }
333
+ {{#if googleLoginEnabled }}
334
334
 
335
335
  // Google login: Navigate directly to Google OAuth flow
336
336
  async function startGoogleLogin() {
@@ -346,7 +346,7 @@
346
346
  const mobileGoogleBtn = document.querySelector('.mobile-google-btn');
347
347
  if (googleBtn) googleBtn.addEventListener('click', startGoogleLogin);
348
348
  if (mobileGoogleBtn) mobileGoogleBtn.addEventListener('click', startGoogleLogin);
349
- { {/if } }
349
+ {{/if}}
350
350
  </script>
351
351
  </body>
352
352