@metaadri/secureauth 1.2.0 → 1.2.1
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
package/src/scaffolder.js
CHANGED
|
@@ -111,8 +111,13 @@ module.exports = {
|
|
|
111
111
|
db: {
|
|
112
112
|
query: (text, params) => {
|
|
113
113
|
const stmt = db.prepare(text);
|
|
114
|
-
const
|
|
115
|
-
|
|
114
|
+
const sql = text.trim().toUpperCase();
|
|
115
|
+
if (sql.startsWith('SELECT')) {
|
|
116
|
+
const rows = params ? stmt.all(...params) : stmt.all();
|
|
117
|
+
return { rows };
|
|
118
|
+
}
|
|
119
|
+
const info = params ? stmt.run(...params) : stmt.run();
|
|
120
|
+
return { rows: [], changes: info.changes };
|
|
116
121
|
}
|
|
117
122
|
}
|
|
118
123
|
};
|
|
@@ -8,7 +8,6 @@ const loginLimiter = createRateLimiter(5, 15);
|
|
|
8
8
|
|
|
9
9
|
router.post('/register', authController.register);
|
|
10
10
|
router.post('/login', loginLimiter, authController.loginStep1);
|
|
11
|
-
router.post('/demo/login', authController.demoLogin);
|
|
12
11
|
router.post('/verify-2fa', loginLimiter, authController.verifyTOTP);
|
|
13
12
|
router.get('/dashboard', checkAndRefreshToken, authController.getDashboard);
|
|
14
13
|
router.get('/login-history', checkAndRefreshToken, authController.getLoginHistory);
|
package/templates/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require('
|
|
1
|
+
const path = require('path');
|
|
2
|
+
require('dotenv').config({ path: path.join(__dirname, '.env') });
|
|
2
3
|
const express = require('express');
|
|
3
4
|
const cors = require('cors');
|
|
4
|
-
const path = require('path');
|
|
5
5
|
const helmet = require('helmet');
|
|
6
6
|
|
|
7
7
|
const authRoutes = require('./routes/authRoutes');
|
|
@@ -62,16 +62,15 @@ app.get('/', (req, res) => {
|
|
|
62
62
|
|
|
63
63
|
let dbReady = false;
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.
|
|
73
|
-
|
|
74
|
-
});
|
|
65
|
+
try {
|
|
66
|
+
initDatabase();
|
|
67
|
+
seedAdminUser();
|
|
68
|
+
seedDemoUser();
|
|
69
|
+
dbReady = true;
|
|
70
|
+
console.log('Database initialized and seeded');
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.error('Database initialization failed:', err.message);
|
|
73
|
+
}
|
|
75
74
|
|
|
76
75
|
app.use((req, res, next) => {
|
|
77
76
|
if (dbReady) return next();
|