mbkauthe 1.1.15 → 1.1.17

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/lib/main.js CHANGED
@@ -14,8 +14,6 @@ import speakeasy from "speakeasy";
14
14
  import { createRequire } from "module";
15
15
  import fs from "fs";
16
16
  import path from "path";
17
- import { marked } from "marked";
18
- import * as cheerio from 'cheerio';
19
17
 
20
18
  import dotenv from "dotenv";
21
19
  dotenv.config();
@@ -316,28 +314,14 @@ router.post("/mbkauthe/api/logout", async (req, res) => {
316
314
  }
317
315
  });
318
316
 
319
-
320
-
321
-
322
-
323
-
324
-
325
-
326
-
327
-
328
-
329
-
330
-
331
-
332
-
333
-
334
-
335
317
  router.get("/mbkauthe/login", LoginLimit, (req, res) => {
336
318
  return res.render("loginmbkauthe.handlebars", {
337
319
  layout: false,
338
320
  customURL: mbkautheVar.loginRedirectURL || '/home',
339
321
  userLoggedIn: !!req.session?.user,
340
- username: req.session?.user?.username || ''
322
+ username: req.session?.user?.username || '',
323
+ version: packageJson.version,
324
+ appName: mbkautheVar.APP_NAME.toUpperCase(),
341
325
  });
342
326
  });
343
327
 
@@ -434,6 +418,8 @@ router.get(["/mbkauthe/info", "/mbkauthe/i"], LoginLimit, async (_, res) => {
434
418
  <html>
435
419
  <head>
436
420
  <title>Version and Configuration Information</title>
421
+ <link rel="icon" type="image/x-icon" href="https://mbktechstudio.com/Assets/Images/Icon/dgicon.svg">
422
+
437
423
  <style>
438
424
  :root {
439
425
  --bg-color: #121212;
@@ -717,6 +703,10 @@ router.get(["/mbkauthe/info", "/mbkauthe/i"], LoginLimit, async (_, res) => {
717
703
  <div class="info-label">DOMAIN:</div>
718
704
  <div class="info-value">${mbkautheVar.DOMAIN}</div>
719
705
  </div>
706
+ <div class="info-row">
707
+ <div class="info-label">Login Redirect URL:</div>
708
+ <div class="info-value">${mbkautheVar.loginRedirectURL}</div>
709
+ </div>
720
710
  </div>
721
711
 
722
712
  <div class="info-section">
@@ -36,7 +36,7 @@ async function validateSession(req, res, next) {
36
36
  if (!req.session.user) {
37
37
  console.log("User not authenticated");
38
38
  console.log(req.session.user);
39
- return res.render("error.handlebars", {
39
+ return res.render("Error/dError.handlebars", {
40
40
  layout: false,
41
41
  code: 401,
42
42
  error: "Not Logged In",
@@ -59,7 +59,7 @@ async function validateSession(req, res, next) {
59
59
  res.clearCookie("mbkauthe.sid", cookieOptions);
60
60
  res.clearCookie("sessionId", cookieOptions);
61
61
  res.clearCookie("username", cookieOptions);
62
- return res.render("error.handlebars", {
62
+ return res.render("Error/dError.handlebars", {
63
63
  layout: false,
64
64
  code: 401,
65
65
  error: "Session Expired",
@@ -76,7 +76,7 @@ async function validateSession(req, res, next) {
76
76
  res.clearCookie("mbkauthe.sid", cookieOptions);
77
77
  res.clearCookie("sessionId", cookieOptions);
78
78
  res.clearCookie("username", cookieOptions);
79
- return res.render("error.handlebars", {
79
+ return res.render("Error/dError.handlebars", {
80
80
  layout: false,
81
81
  code: 401,
82
82
  error: "Account Inactive",
@@ -95,7 +95,7 @@ async function validateSession(req, res, next) {
95
95
  res.clearCookie("mbkauthe.sid", cookieOptions);
96
96
  res.clearCookie("sessionId", cookieOptions);
97
97
  res.clearCookie("username", cookieOptions);
98
- return res.render("error.handlebars", {
98
+ return res.render("Error/dError.handlebars", {
99
99
  layout: false,
100
100
  code: 401,
101
101
  error: "Unauthorized",
@@ -119,7 +119,7 @@ const checkRolePermission = (requiredRole) => {
119
119
  if (!req.session || !req.session.user || !req.session.user.id) {
120
120
  console.log("User not authenticated");
121
121
  console.log(req.session);
122
- return res.render("error.handlebars", {
122
+ return res.render("Error/dError.handlebars", {
123
123
  layout: false,
124
124
  code: 401,
125
125
  error: "Not Logged In",
@@ -144,7 +144,7 @@ const checkRolePermission = (requiredRole) => {
144
144
 
145
145
  const userRole = result.rows[0].Role;
146
146
  if (userRole !== requiredRole) {
147
- return res.render("error.handlebars", {
147
+ return res.render("Error/dError.handlebars", {
148
148
  layout: false,
149
149
  code: 403,
150
150
  error: "Access Denied",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mbkauthe",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "description": "MBKTechStudio's reusable authentication system for Node.js applications.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,6 +1,5 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
- {{> script/showmessage }}
4
3
 
5
4
  <head>
6
5
  <meta charset="UTF-8">
@@ -260,7 +259,7 @@
260
259
  }
261
260
 
262
261
  .terms-info {
263
- margin-top: 2rem;
262
+ margin-top: 1rem;
264
263
  font-size: 0.8rem;
265
264
  color: var(--gray);
266
265
  text-align: center;
@@ -350,6 +349,13 @@
350
349
  .login-title {
351
350
  font-size: 1.8rem;
352
351
  }
352
+
353
+ .version-info {
354
+ bottom: 10px;
355
+ right: 10px;
356
+ font-size: 0.7rem;
357
+ padding: 6px 10px;
358
+ }
353
359
  }
354
360
 
355
361
  @media (max-width: 576px) {
@@ -427,6 +433,29 @@
427
433
  text-align: center;
428
434
  box-shadow: var(--shadow-sm);
429
435
  }
436
+
437
+ .logo-comp {
438
+ font-size: 1rem;
439
+ }
440
+
441
+ .version-info {
442
+ position: fixed;
443
+ bottom: 20px;
444
+ right: 20px;
445
+ background: var(--dark-light);
446
+ color: var(--gray);
447
+ padding: 8px 12px;
448
+ border-radius: var(--radius-sm);
449
+ font-size: 0.75rem;
450
+ border: 1px solid var(--glass-border);
451
+ z-index: 999;
452
+ transition: var(--transition);
453
+ }
454
+
455
+ .version-info:hover {
456
+ color: var(--primary);
457
+ border-color: var(--primary);
458
+ }
430
459
  </style>
431
460
  </head>
432
461
 
@@ -436,12 +465,185 @@
436
465
  <div class="navbar">
437
466
  <a class="logo">
438
467
  <img src="https://mbktechstudio.com/Assets/Images/Icon/dgicon.svg" alt="MBK Tech Studio Logo">
439
- <span class="logo-text">MBK Authe</span>
468
+ <span class="logo-text">{{appName}} <span class="logo-comp">MBKTECHStudio</span></span>
440
469
  </a>
441
470
  </div>
442
471
  </nav>
443
472
  </header>
444
473
 
474
+ <div>
475
+ <div class="showMessageblurWindow">
476
+ <div class="showmessageWindow">
477
+ <h1></h1>
478
+ <p></p>
479
+ <a href="" target="_blank" class="error-code"></a>
480
+ <button class="btn btn-save full" style="font-size: 20px; margin-top: 10px;"
481
+ onclick="hideMessage()">Okay</button>
482
+ </div>
483
+ </div>
484
+ <script>
485
+ // showMessage("Failed to load the page. Please try again later.", "Error", "404");
486
+ function showMessage(message, heading, errorCode) {
487
+ document.querySelector(".showmessageWindow h1").innerText = heading;
488
+ document.querySelector(".showmessageWindow p").innerHTML = message;
489
+ if (errorCode) {
490
+ document.querySelector(".showmessageWindow .error-code").style.display = "block";
491
+ document.querySelector(".showmessageWindow .error-code").innerText = `Error Code: ${errorCode}`;
492
+ } else {
493
+ document.querySelector(".showmessageWindow .error-code").style.display = "none";
494
+ }
495
+ document.querySelector(".showmessageWindow .error-code").href = `https://mbktechstudio.com/ErrorCode/#${errorCode}`;
496
+ document
497
+ .querySelector(".showMessageblurWindow")
498
+ .classList
499
+ .add("active");
500
+ document
501
+ .body
502
+ .classList
503
+ .add("blur-active");
504
+ }
505
+ function hideMessage() {
506
+ const blurWindow = document.querySelector(".showMessageblurWindow");
507
+ blurWindow.classList.add("fade-out");
508
+ setTimeout(() => {
509
+ blurWindow.classList.remove("active", "fade-out");
510
+ document
511
+ .body
512
+ .classList
513
+ .remove("blur-active");
514
+ }, 500);
515
+ }
516
+ </script>
517
+ <style>
518
+ .showMessageblurWindow {
519
+ position: fixed;
520
+ top: 0;
521
+ left: 0;
522
+ width: 100%;
523
+ height: 100%;
524
+ background: rgba(0, 0, 0, 0.5);
525
+ display: none;
526
+ justify-content: center;
527
+ align-items: center;
528
+ z-index: 1000;
529
+ backdrop-filter: blur(10px);
530
+ }
531
+
532
+ .showMessageblurWindow.active {
533
+ display: flex;
534
+ }
535
+
536
+ .showMessageblurWindow.fade-out {
537
+ animation: fadeOut 0.5s ease-in-out forwards;
538
+ }
539
+
540
+ body.blur-active {
541
+ overflow: hidden;
542
+ }
543
+
544
+ .showmessageWindow {
545
+ display: flex;
546
+ flex-direction: column;
547
+ align-items: center;
548
+ justify-content: center;
549
+ font-family: 'Roboto', sans-serif;
550
+ background: rgba(0, 0, 0, 0.6);
551
+ padding: 20px 30px;
552
+ border-radius: 15px;
553
+ max-width: 90%;
554
+ width: 600px;
555
+ position: relative;
556
+ color: #fff;
557
+ border: 2px solid #007bff;
558
+ animation: fadeIn 0.5s ease-in-out;
559
+ }
560
+
561
+ .showmessageWindow h1 {
562
+ font-family: 'Roboto', sans-serif;
563
+ margin-top: 0;
564
+ font-size: 30px;
565
+ text-align: center;
566
+ color: #fff;
567
+ text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
568
+ margin-bottom: 10px;
569
+ }
570
+
571
+ .showmessageWindow p {
572
+ font-family: 'Roboto', sans-serif;
573
+ font-size: 18px;
574
+ text-align: center;
575
+ color: #ddd;
576
+ }
577
+
578
+ .showmessageWindow .close-btn {
579
+ position: absolute;
580
+ top: 10px;
581
+ right: 10px;
582
+ background: none;
583
+ border: none;
584
+ font-size: 30px;
585
+ cursor: pointer;
586
+ color: #bbb;
587
+ transition: color 0.3s;
588
+ }
589
+
590
+ .showmessageWindow .close-btn:hover {
591
+ color: #fff;
592
+ }
593
+
594
+ @keyframes fadeIn {
595
+ from {
596
+ opacity: 0;
597
+ transform: scale(0.9);
598
+ }
599
+
600
+ to {
601
+ opacity: 1;
602
+ transform: scale(1);
603
+ }
604
+ }
605
+
606
+ .showmessageWindow .error-code {
607
+ font-family: 'Roboto', sans-serif;
608
+ font-size: 16px;
609
+ text-align: center;
610
+ color: #ff4d4d;
611
+ font-weight: 700;
612
+ margin: 10px auto;
613
+ padding: 5px 10px;
614
+ background: rgba(255, 77, 77, 0.1);
615
+ border: 1px solid #ff4d4d;
616
+ border-radius: 5px;
617
+ display: inline-block;
618
+ transition: all 0.3s ease-in;
619
+ }
620
+
621
+ .showmessageWindow .error-code:hover {
622
+ background: rgba(255, 77, 77, 0.2);
623
+ color: #007bff;
624
+ text-decoration: none;
625
+ transition: all 0.3s ease-out;
626
+ }
627
+
628
+
629
+ .showmessageWindow .btn-save {
630
+ width: 100%;
631
+ }
632
+
633
+ @keyframes fadeOut {
634
+ from {
635
+ opacity: 1;
636
+ transform: scale(1);
637
+ }
638
+
639
+ to {
640
+ opacity: 0;
641
+ transform: scale(0.9);
642
+ }
643
+ }
644
+ </style>
645
+ </div>
646
+
445
647
  <section class="login-container">
446
648
 
447
649
  <i class="fas fa-robot ai-element"></i>
@@ -502,14 +704,21 @@
502
704
 
503
705
  <p class="terms-info">
504
706
  By logging in, you agree to our
505
- <a href="/info/Terms&Conditions" target="_blank" class="terms-link">Terms & Conditions</a>
707
+ <a href="https://portal.mbktechstudio.com/info/Terms&Conditions" target="_blank"
708
+ class="terms-link">Terms & Conditions</a>
506
709
  and
507
- <a href="/info/PrivacyPolicy" target="_blank" class="terms-link">Privacy Policy</a>.
710
+ <a href="https://portal.mbktechstudio.com/info/PrivacyPolicy" target="_blank"
711
+ class="terms-link">Privacy Policy</a>.
508
712
  </p>
509
713
  </form>
510
714
  </div>
511
715
  </section>
512
716
 
717
+ <!-- Version Info -->
718
+ <div class="version-info">
719
+ v{{version}}
720
+ </div>
721
+
513
722
  <script>
514
723
 
515
724
  // Toggle password visibility