@sonicjs-cms/core 2.3.17 → 2.4.0
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/dist/{chunk-IEWLOVP3.cjs → chunk-2MI3LZFH.cjs} +2 -2
- package/dist/{chunk-IEWLOVP3.cjs.map → chunk-2MI3LZFH.cjs.map} +1 -1
- package/dist/{chunk-YHJB26RJ.cjs → chunk-7I5INVNR.cjs} +4 -4
- package/dist/{chunk-YHJB26RJ.cjs.map → chunk-7I5INVNR.cjs.map} +1 -1
- package/dist/{chunk-74DP754U.cjs → chunk-A4SVOGG6.cjs} +143 -96
- package/dist/chunk-A4SVOGG6.cjs.map +1 -0
- package/dist/{chunk-B6YJRVFQ.js → chunk-D2NLCPO2.js} +2 -2
- package/dist/{chunk-B6YJRVFQ.js.map → chunk-D2NLCPO2.js.map} +1 -1
- package/dist/{chunk-VYL6RIV6.js → chunk-DXM575E2.js} +3 -3
- package/dist/{chunk-VYL6RIV6.js.map → chunk-DXM575E2.js.map} +1 -1
- package/dist/{chunk-QBWD6FKH.js → chunk-FT6NBHNX.js} +61 -15
- package/dist/chunk-FT6NBHNX.js.map +1 -0
- package/dist/{chunk-2XCJ3HT5.cjs → chunk-FYEDK7K7.cjs} +3 -3
- package/dist/{chunk-2XCJ3HT5.cjs.map → chunk-FYEDK7K7.cjs.map} +1 -1
- package/dist/{chunk-TMQOLXLY.js → chunk-VNCYCH3H.js} +3 -3
- package/dist/{chunk-TMQOLXLY.js.map → chunk-VNCYCH3H.js.map} +1 -1
- package/dist/index.cjs +104 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -7
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +23 -23
- package/dist/middleware.js +2 -2
- package/dist/migrations-32QAYLWJ.cjs +13 -0
- package/dist/{migrations-EOV7NJZ7.cjs.map → migrations-32QAYLWJ.cjs.map} +1 -1
- package/dist/migrations-57ZHBQ4X.js +4 -0
- package/dist/{migrations-6HKPNPTK.js.map → migrations-57ZHBQ4X.js.map} +1 -1
- package/dist/routes.cjs +24 -24
- package/dist/routes.js +4 -4
- package/dist/services.cjs +2 -2
- package/dist/services.js +1 -1
- package/dist/utils.cjs +11 -11
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-74DP754U.cjs.map +0 -1
- package/dist/chunk-QBWD6FKH.js.map +0 -1
- package/dist/migrations-6HKPNPTK.js +0 -4
- package/dist/migrations-EOV7NJZ7.cjs +0 -13
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk7FOAMNTI_cjs = require('./chunk-7FOAMNTI.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunk7I5INVNR_cjs = require('./chunk-7I5INVNR.cjs');
|
|
5
5
|
var chunkILZ3DP4I_cjs = require('./chunk-ILZ3DP4I.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunk2MI3LZFH_cjs = require('./chunk-2MI3LZFH.cjs');
|
|
7
7
|
var chunkAZLU3ROK_cjs = require('./chunk-AZLU3ROK.cjs');
|
|
8
|
-
var
|
|
8
|
+
var chunkFYEDK7K7_cjs = require('./chunk-FYEDK7K7.cjs');
|
|
9
9
|
var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
|
|
10
10
|
var hono = require('hono');
|
|
11
11
|
var cors = require('hono/cors');
|
|
@@ -44,7 +44,7 @@ apiContentCrudRoutes.get("/:id", async (c) => {
|
|
|
44
44
|
}, 500);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
apiContentCrudRoutes.post("/",
|
|
47
|
+
apiContentCrudRoutes.post("/", chunk7I5INVNR_cjs.requireAuth(), async (c) => {
|
|
48
48
|
try {
|
|
49
49
|
const db = c.env.DB;
|
|
50
50
|
const user = c.get("user");
|
|
@@ -110,7 +110,7 @@ apiContentCrudRoutes.post("/", chunkYHJB26RJ_cjs.requireAuth(), async (c) => {
|
|
|
110
110
|
}, 500);
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
apiContentCrudRoutes.put("/:id",
|
|
113
|
+
apiContentCrudRoutes.put("/:id", chunk7I5INVNR_cjs.requireAuth(), async (c) => {
|
|
114
114
|
try {
|
|
115
115
|
const id = c.req.param("id");
|
|
116
116
|
const db = c.env.DB;
|
|
@@ -174,7 +174,7 @@ apiContentCrudRoutes.put("/:id", chunkYHJB26RJ_cjs.requireAuth(), async (c) => {
|
|
|
174
174
|
}, 500);
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
-
apiContentCrudRoutes.delete("/:id",
|
|
177
|
+
apiContentCrudRoutes.delete("/:id", chunk7I5INVNR_cjs.requireAuth(), async (c) => {
|
|
178
178
|
try {
|
|
179
179
|
const id = c.req.param("id");
|
|
180
180
|
const db = c.env.DB;
|
|
@@ -210,7 +210,7 @@ apiRoutes.use("*", async (c, next) => {
|
|
|
210
210
|
c.header("X-Response-Time", `${totalTime}ms`);
|
|
211
211
|
});
|
|
212
212
|
apiRoutes.use("*", async (c, next) => {
|
|
213
|
-
const cacheEnabled = await
|
|
213
|
+
const cacheEnabled = await chunk7I5INVNR_cjs.isPluginActive(c.env.DB, "core-cache");
|
|
214
214
|
c.set("cacheEnabled", cacheEnabled);
|
|
215
215
|
await next();
|
|
216
216
|
});
|
|
@@ -335,12 +335,12 @@ apiRoutes.get("/content", async (c) => {
|
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
const filter =
|
|
338
|
+
const filter = chunkFYEDK7K7_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
339
339
|
if (!filter.limit) {
|
|
340
340
|
filter.limit = 50;
|
|
341
341
|
}
|
|
342
342
|
filter.limit = Math.min(filter.limit, 1e3);
|
|
343
|
-
const builder3 = new
|
|
343
|
+
const builder3 = new chunkFYEDK7K7_cjs.QueryFilterBuilder();
|
|
344
344
|
const queryResult = builder3.build("content", filter);
|
|
345
345
|
if (queryResult.errors.length > 0) {
|
|
346
346
|
return c.json({
|
|
@@ -427,7 +427,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
427
427
|
if (!collectionResult) {
|
|
428
428
|
return c.json({ error: "Collection not found" }, 404);
|
|
429
429
|
}
|
|
430
|
-
const filter =
|
|
430
|
+
const filter = chunkFYEDK7K7_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
431
431
|
if (!filter.where) {
|
|
432
432
|
filter.where = { and: [] };
|
|
433
433
|
}
|
|
@@ -443,7 +443,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
443
443
|
filter.limit = 50;
|
|
444
444
|
}
|
|
445
445
|
filter.limit = Math.min(filter.limit, 1e3);
|
|
446
|
-
const builder3 = new
|
|
446
|
+
const builder3 = new chunkFYEDK7K7_cjs.QueryFilterBuilder();
|
|
447
447
|
const queryResult = builder3.build("content", filter);
|
|
448
448
|
if (queryResult.errors.length > 0) {
|
|
449
449
|
return c.json({
|
|
@@ -568,7 +568,7 @@ var fileValidationSchema = zod.z.object({
|
|
|
568
568
|
// 50MB max
|
|
569
569
|
});
|
|
570
570
|
var apiMediaRoutes = new hono.Hono();
|
|
571
|
-
apiMediaRoutes.use("*",
|
|
571
|
+
apiMediaRoutes.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
572
572
|
apiMediaRoutes.post("/upload", async (c) => {
|
|
573
573
|
try {
|
|
574
574
|
const user = c.get("user");
|
|
@@ -1312,8 +1312,8 @@ apiSystemRoutes.get("/env", (c) => {
|
|
|
1312
1312
|
});
|
|
1313
1313
|
var api_system_default = apiSystemRoutes;
|
|
1314
1314
|
var adminApiRoutes = new hono.Hono();
|
|
1315
|
-
adminApiRoutes.use("*",
|
|
1316
|
-
adminApiRoutes.use("*",
|
|
1315
|
+
adminApiRoutes.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
1316
|
+
adminApiRoutes.use("*", chunk7I5INVNR_cjs.requireRole(["admin", "editor"]));
|
|
1317
1317
|
adminApiRoutes.get("/stats", async (c) => {
|
|
1318
1318
|
try {
|
|
1319
1319
|
const db = c.env.DB;
|
|
@@ -1722,7 +1722,7 @@ adminApiRoutes.delete("/collections/:id", async (c) => {
|
|
|
1722
1722
|
});
|
|
1723
1723
|
adminApiRoutes.get("/migrations/status", async (c) => {
|
|
1724
1724
|
try {
|
|
1725
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1725
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-32QAYLWJ.cjs');
|
|
1726
1726
|
const db = c.env.DB;
|
|
1727
1727
|
const migrationService = new MigrationService2(db);
|
|
1728
1728
|
const status = await migrationService.getMigrationStatus();
|
|
@@ -1747,7 +1747,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
1747
1747
|
error: "Unauthorized. Admin access required."
|
|
1748
1748
|
}, 403);
|
|
1749
1749
|
}
|
|
1750
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1750
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-32QAYLWJ.cjs');
|
|
1751
1751
|
const db = c.env.DB;
|
|
1752
1752
|
const migrationService = new MigrationService2(db);
|
|
1753
1753
|
const result = await migrationService.runPendingMigrations();
|
|
@@ -1766,7 +1766,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
1766
1766
|
});
|
|
1767
1767
|
adminApiRoutes.get("/migrations/validate", async (c) => {
|
|
1768
1768
|
try {
|
|
1769
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1769
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-32QAYLWJ.cjs');
|
|
1770
1770
|
const db = c.env.DB;
|
|
1771
1771
|
const migrationService = new MigrationService2(db);
|
|
1772
1772
|
const validation = await migrationService.validateSchema();
|
|
@@ -1993,18 +1993,40 @@ function renderRegisterPage(data) {
|
|
|
1993
1993
|
<div class="flex min-h-full flex-col justify-center py-12 sm:px-6 lg:px-8">
|
|
1994
1994
|
<!-- Logo Section -->
|
|
1995
1995
|
<div class="sm:mx-auto sm:w-full sm:max-w-md text-center">
|
|
1996
|
-
<div class="mx-auto
|
|
1997
|
-
<svg class="
|
|
1998
|
-
<path
|
|
1996
|
+
<div class="mx-auto w-64 mb-8">
|
|
1997
|
+
<svg class="w-full h-auto" viewBox="380 1300 2250 400" aria-hidden="true">
|
|
1998
|
+
<path fill="#F1F2F2" d="M476.851,1404.673h168.536c4.714,0,8.695-1.618,11.944-4.866c3.241-3.241,4.866-7.222,4.866-11.943 c0-2.357-0.443-4.569-1.327-6.636c-0.885-2.06-2.067-3.829-3.539-5.308c-1.479-1.472-3.249-2.654-5.308-3.538 c-2.067-0.885-4.279-1.327-6.635-1.327H476.851c-20.057,0-37.158,7.154-51.313,21.454c-14.155,14.308-21.233,31.483-21.233,51.534 c0,20.058,7.078,37.234,21.233,51.534c14.155,14.308,31.255,21.454,51.313,21.454h112.357c10.907,0,20.196,3.837,27.868,11.502 c7.666,7.672,11.502,16.885,11.502,27.646c0,10.769-3.836,19.982-11.502,27.647c-7.672,7.673-16.961,11.502-27.868,11.502H421.115 c-4.721,0-8.702,1.624-11.944,4.865c-3.248,3.249-4.866,7.23-4.866,11.944c0,3.248,0.733,6.123,2.212,8.626 c1.472,2.509,3.462,4.499,5.971,5.972c2.502,1.472,5.378,2.212,8.626,2.212h168.094c20.052,0,37.227-7.078,51.534-21.234 c14.3-14.155,21.454-31.331,21.454-51.534c0-20.196-7.154-37.379-21.454-51.534c-14.308-14.156-31.483-21.234-51.534-21.234 H476.851c-10.616,0-19.76-3.905-27.426-11.721c-7.672-7.811-11.501-17.101-11.501-27.87c0-10.761,3.829-19.975,11.501-27.647 C457.091,1408.508,466.235,1404.673,476.851,1404.673z"></path>
|
|
1999
|
+
<path fill="#F1F2F2" d="M974.78,1398.211c-5.016,6.574-10.034,13.146-15.048,19.721c-1.828,2.398-3.657,4.796-5.487,7.194 c1.994,1.719,3.958,3.51,5.873,5.424c18.724,18.731,28.089,41.216,28.089,67.459c0,26.251-9.366,48.658-28.089,67.237 c-18.731,18.579-41.215,27.868-67.459,27.868c-9.848,0-19.156-1.308-27.923-3.923l-4.185,3.354 c-8.587,6.885-17.154,13.796-25.725,20.702c17.52,8.967,36.86,13.487,58.054,13.487c35.533,0,65.91-12.608,91.124-37.821 c25.214-25.215,37.821-55.584,37.821-91.125c0-35.534-12.607-65.911-37.821-91.126 C981.004,1403.663,977.926,1400.854,974.78,1398.211z"></path>
|
|
2000
|
+
<path fill="#F1F2F2" d="M1364.644,1439.619c-4.72,0-8.702,1.624-11.943,4.865c-3.249,3.249-4.866,7.23-4.866,11.944v138.014 l-167.651-211.003c-0.297-0.586-0.74-1.03-1.327-1.326c-4.721-4.714-10.249-7.742-16.588-9.069 c-6.346-1.326-12.608-0.732-18.801,1.77c-6.192,2.509-11.059,6.49-14.598,11.944c-3.539,5.46-5.308,11.577-5.308,18.357v208.348 c0,4.721,1.618,8.703,4.866,11.944c3.241,3.241,7.222,4.865,11.943,4.865c2.945,0,5.751-0.738,8.405-2.211 c2.654-1.472,4.713-3.463,6.193-5.971c1.473-2.503,2.212-5.378,2.212-8.627v-205.251l166.325,209.675 c2.06,2.654,4.423,4.865,7.078,6.635c5.308,3.829,11.349,5.75,18.137,5.75c5.308,0,10.464-1.182,15.482-3.538 c3.539-1.769,6.56-4.127,9.069-7.078c2.502-2.945,4.491-6.338,5.971-10.175c1.473-3.829,2.212-7.664,2.212-11.501v-141.552 c0-4.714-1.624-8.695-4.865-11.944C1373.339,1441.243,1369.359,1439.619,1364.644,1439.619z"></path>
|
|
2001
|
+
<path fill="#F1F2F2" d="M1508.406,1432.983c-2.654-1.472-5.46-2.212-8.404-2.212c-4.721,0-8.703,1.7-11.944,5.087 c-3.249,3.395-4.865,7.3-4.865,11.723v163.228c0,4.721,1.616,8.702,4.865,11.943c3.241,3.249,7.223,4.866,11.944,4.866 c2.944,0,5.751-0.732,8.404-2.212c2.655-1.472,4.714-3.539,6.193-6.194c1.473-2.654,2.213-5.453,2.213-8.404V1447.58 c0-2.945-0.74-5.75-2.213-8.405C1513.12,1436.522,1511.06,1434.462,1508.406,1432.983z"></path>
|
|
2002
|
+
<path fill="#F1F2F2" d="M1499.78,1367.957c-4.575,0-8.481,1.625-11.722,4.866c-3.249,3.249-4.865,7.23-4.865,11.943 c0,2.951,0.732,5.75,2.212,8.405c1.472,2.654,3.463,4.721,5.971,6.193c2.503,1.479,5.378,2.212,8.627,2.212 c4.423,0,8.328-1.618,11.721-4.865c3.387-3.243,5.088-7.224,5.088-11.944c0-4.713-1.701-8.694-5.088-11.943 C1508.33,1369.582,1504.349,1367.957,1499.78,1367.957z"></path>
|
|
2003
|
+
<path fill="#F1F2F2" d="M1859.627,1369.727H1747.27c-35.388,0-65.69,12.607-90.904,37.821 c-25.213,25.215-37.82,55.591-37.82,91.125c0,35.54,12.607,65.911,37.82,91.125c25.215,25.215,55.516,37.821,90.904,37.821h56.178 c4.714,0,8.695-1.618,11.944-4.866c3.241-3.241,4.865-7.222,4.865-11.943c0-4.714-1.624-8.695-4.865-11.943 c-3.249-3.243-7.23-4.866-11.944-4.866h-56.178c-26.251,0-48.659-9.359-67.237-28.09c-18.579-18.723-27.868-41.207-27.868-67.459 c0-26.243,9.29-48.659,27.868-67.237c18.579-18.579,40.987-27.868,67.237-27.868h112.357c4.714,0,8.696-1.693,11.944-5.087 c3.241-3.387,4.865-7.368,4.865-11.943c0-4.569-1.624-8.475-4.865-11.723C1868.322,1371.351,1864.341,1369.727,1859.627,1369.727z "></path>
|
|
2004
|
+
<path fill="#06b6d4" d="M2219.256,1371.054h-112.357c-4.423,0-8.336,1.624-11.723,4.865c-3.393,3.249-5.087,7.23-5.087,11.944 c0,4.721,1.694,8.702,5.087,11.943c3.387,3.249,7.3,4.866,11.723,4.866h95.547v95.105c0,26.251-9.365,48.659-28.088,67.237 c-18.731,18.579-41.215,27.868-67.459,27.868c-26.251,0-48.659-9.289-67.237-27.868c-18.579-18.579-27.868-40.987-27.868-67.237 c0-4.713-1.701-8.771-5.088-12.165c-3.393-3.387-7.374-5.087-11.943-5.087c-4.575,0-8.481,1.7-11.722,5.087 c-3.249,3.393-4.865,7.451-4.865,12.165c0,35.388,12.607,65.69,37.82,90.904c25.215,25.213,55.584,37.82,91.126,37.82 c35.532,0,65.91-12.607,91.125-37.82c25.214-25.215,37.82-55.516,37.82-90.904v-111.915c0-4.714-1.624-8.695-4.865-11.944 C2227.951,1372.678,2223.971,1371.054,2219.256,1371.054z"></path>
|
|
2005
|
+
<path fill="#06b6d4" d="M2574.24,1502.875c-14.306-14.156-31.483-21.234-51.533-21.234H2410.35 c-10.617,0-19.762-3.829-27.426-11.501c-7.672-7.664-11.501-16.954-11.501-27.868c0-10.907,3.829-20.196,11.501-27.868 c7.664-7.664,16.809-11.501,27.426-11.501h112.357c4.714,0,8.695-1.617,11.944-4.866c3.241-3.241,4.865-7.222,4.865-11.943 c0-4.714-1.624-8.695-4.865-11.944c-3.249-3.241-7.23-4.865-11.944-4.865H2410.35c-20.058,0-37.158,7.154-51.313,21.454 c-14.156,14.308-21.232,31.483-21.232,51.534c0,20.058,7.077,37.234,21.232,51.534c14.156,14.308,31.255,21.454,51.313,21.454 h112.357c7.078,0,13.637,1.77,19.684,5.308c6.042,3.539,10.838,8.336,14.377,14.377c3.538,6.047,5.307,12.607,5.307,19.685 c0,10.616-3.835,19.76-11.501,27.425c-7.672,7.673-16.961,11.502-27.868,11.502h-168.094c-4.721,0-8.703,1.7-11.944,5.087 c-3.249,3.393-4.865,7.374-4.865,11.943c0,4.576,1.616,8.481,4.865,11.723c3.241,3.249,7.223,4.866,11.944,4.866h168.094 c20.051,0,37.227-7.078,51.533-21.234c14.302-14.155,21.454-31.331,21.454-51.534 C2595.695,1534.213,2588.542,1517.03,2574.24,1502.875z"></path>
|
|
2006
|
+
<path fill="#06b6d4" d="M854.024,1585.195l20.001-16.028c16.616-13.507,33.04-27.265,50.086-40.251 c1.13-0.861,2.9-1.686,2.003-3.516c-0.843-1.716-2.481-2.302-4.484-2.123c-8.514,0.765-17.016-0.538-25.537-0.353 c-1.124,0.024-2.768,0.221-3.163-1.25c-0.371-1.369,1.088-2.063,1.919-2.894c6.26-6.242,12.574-12.43,18.816-18.691 c9.303-9.327,18.565-18.714,27.851-28.066c1.848-1.859,3.701-3.713,5.549-5.572c2.655-2.661,5.309-5.315,7.958-7.982 c0.574-0.579,1.259-1.141,1.246-1.94c-0.004-0.257-0.078-0.538-0.254-0.853c-0.556-0.981-1.441-1.1-2.469-0.957 c-0.658,0.096-1.315,0.185-1.973,0.275c-3.844,0.538-7.689,1.076-11.533,1.608c-3.641,0.505-7.281,1.02-10.922,1.529 c-4.162,0.582-8.324,1.158-12.486,1.748c-1.142,0.161-2.409,1.662-3.354,0.508c-0.419-0.508-0.431-1.028-0.251-1.531 c0.269-0.741,0.957-1.441,1.387-2.021c3.414-4.58,6.882-9.124,10.356-13.662c1.74-2.272,3.48-4.544,5.214-6.822 c4.682-6.141,9.369-12.281,14.051-18.422c0.09-0.119,0.181-0.237,0.271-0.355c6.848-8.98,13.7-17.958,20.553-26.936 c0.488-0.64,0.977-1.28,1.465-1.92c2.159-2.828,4.315-5.658,6.476-8.486c4.197-5.501,8.454-10.954,12.67-16.442 c0.263-0.347,0.538-0.718,0.717-1.106c0.269-0.586,0.299-1.196-0.335-1.776c-0.825-0.753-1.8-0.15-2.595,0.419 c-0.67,0.472-1.333,0.957-1.955,1.489c-2.206,1.889-4.401,3.797-6.595,5.698c-3.958,3.438-7.922,6.876-11.976,10.194 c-2.443,2.003-4.865,4.028-7.301,6.038c-18.689-10.581-39.53-15.906-62.549-15.906c-35.54,0-65.911,12.607-91.125,37.82 c-25.214,25.215-37.821,55.592-37.821,91.126c0,35.54,12.607,65.91,37.821,91.125c4.146,4.146,8.445,7.916,12.87,11.381 c-9.015,11.14-18.036,22.277-27.034,33.429c-1.208,1.489-3.755,3.151-2.745,4.891c0.078,0.144,0.173,0.281,0.305,0.425 c1.321,1.429,3.492-1.303,4.933-2.457c6.673-5.333,13.333-10.685,19.982-16.042c3.707-2.984,7.417-5.965,11.124-8.952 c1.474-1.188,2.951-2.373,4.425-3.561c6.41-5.164,12.816-10.333,19.238-15.481L854.024,1585.195z M797.552,1498.009 c0-26.243,9.29-48.728,27.868-67.459c18.579-18.723,40.987-28.089,67.238-28.089c12.273,0,23.712,2.075,34.34,6.171 c-3.37,2.905-6.734,5.816-10.069,8.762c-6.075,5.351-12.365,10.469-18.667,15.564c-4.179,3.378-8.371,6.744-12.514,10.164 c-7.54,6.23-15.037,12.52-22.529,18.804c-7.091,5.955-14.182,11.904-21.19,17.949c-1.136,0.974-3.055,1.907-2.135,3.94 c0.831,1.836,2.774,1.417,4.341,1.578l12.145-0.599l14.151-0.698c1.031-0.102,2.192-0.257,2.89,0.632 c0.034,0.044,0.073,0.078,0.106,0.127c1.017,1.561-0.67,2.105-1.387,2.942c-6.308,7.318-12.616,14.637-18.978,21.907 c-8.161,9.339-16.353,18.649-24.544,27.958c-2.146,2.433-4.275,4.879-6.422,7.312c-1.034,1.172-2.129,2.272-1.238,3.922 c0.933,1.728,2.685,1.752,4.323,1.602c4.134-0.367,8.263-0.489,12.396-0.492c0.242,0,0.485-0.005,0.728-0.004 c2.711,0.009,5.422,0.068,8.134,0.145c2.582,0.074,5.166,0.165,7.752,0.249c0.275,1.62-0.879,2.356-1.62,3.259 c-1.333,1.626-2.667,3.247-4,4.867c-4.315,5.252-8.62,10.514-12.928,15.772c-3.562-2.725-7.007-5.733-10.324-9.051 C806.842,1546.667,797.552,1524.26,797.552,1498.009z"></path>
|
|
1999
2007
|
</svg>
|
|
2000
2008
|
</div>
|
|
2001
|
-
<
|
|
2002
|
-
|
|
2009
|
+
<h2 class="mt-6 text-xl font-medium text-white">${data.isSetup ? "Welcome to SonicJS" : "Create Account"}</h2>
|
|
2010
|
+
${data.isSetup ? `<p class="mt-2 text-sm text-zinc-400">Create your admin account to get started.</p>` : `<p class="mt-2 text-sm text-zinc-400">Create your account and get started</p>`}
|
|
2003
2011
|
</div>
|
|
2004
2012
|
|
|
2005
2013
|
<!-- Form Container -->
|
|
2006
2014
|
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
|
2007
2015
|
<div class="bg-zinc-900 shadow-sm ring-1 ring-white/10 rounded-xl px-6 py-8 sm:px-10">
|
|
2016
|
+
<!-- Setup Banner -->
|
|
2017
|
+
${data.isSetup ? `
|
|
2018
|
+
<div class="mb-6 rounded-lg bg-blue-500/10 p-4 ring-1 ring-blue-500/20">
|
|
2019
|
+
<div class="flex items-start gap-x-3">
|
|
2020
|
+
<svg class="h-5 w-5 text-blue-400 shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
2021
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
2022
|
+
</svg>
|
|
2023
|
+
<div class="flex-1">
|
|
2024
|
+
<p class="text-sm font-medium text-blue-300">First-time Setup</p>
|
|
2025
|
+
<p class="text-sm text-blue-400/80 mt-1">This account will be the administrator with full access to manage your SonicJS installation.</p>
|
|
2026
|
+
</div>
|
|
2027
|
+
</div>
|
|
2028
|
+
</div>
|
|
2029
|
+
` : ""}
|
|
2008
2030
|
<!-- Alerts -->
|
|
2009
2031
|
${data.error ? `<div class="mb-6">${chunkAZLU3ROK_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
|
|
2010
2032
|
|
|
@@ -2119,6 +2141,7 @@ function renderRegisterPage(data) {
|
|
|
2119
2141
|
</html>
|
|
2120
2142
|
`;
|
|
2121
2143
|
}
|
|
2144
|
+
var adminExistsCache = null;
|
|
2122
2145
|
async function isRegistrationEnabled(db) {
|
|
2123
2146
|
try {
|
|
2124
2147
|
const plugin = await db.prepare("SELECT settings FROM plugins WHERE id = ?").bind("core-auth").first();
|
|
@@ -2140,6 +2163,21 @@ async function isFirstUserRegistration(db) {
|
|
|
2140
2163
|
return false;
|
|
2141
2164
|
}
|
|
2142
2165
|
}
|
|
2166
|
+
async function checkAdminUserExists(db) {
|
|
2167
|
+
if (adminExistsCache !== null) {
|
|
2168
|
+
return adminExistsCache;
|
|
2169
|
+
}
|
|
2170
|
+
try {
|
|
2171
|
+
const result = await db.prepare("SELECT id FROM users WHERE role = ?").bind("admin").first();
|
|
2172
|
+
adminExistsCache = !!result;
|
|
2173
|
+
return adminExistsCache;
|
|
2174
|
+
} catch {
|
|
2175
|
+
return false;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
function setAdminExists() {
|
|
2179
|
+
adminExistsCache = true;
|
|
2180
|
+
}
|
|
2143
2181
|
var baseRegistrationSchema = zod.z.object({
|
|
2144
2182
|
email: zod.z.string().email("Valid email is required"),
|
|
2145
2183
|
password: zod.z.string().min(8, "Password must be at least 8 characters"),
|
|
@@ -2201,8 +2239,11 @@ authRoutes.get("/register", async (c) => {
|
|
|
2201
2239
|
}
|
|
2202
2240
|
}
|
|
2203
2241
|
const error = c.req.query("error");
|
|
2242
|
+
const isSetup = c.req.query("setup") === "true";
|
|
2204
2243
|
const pageData = {
|
|
2205
|
-
error: error || void 0
|
|
2244
|
+
error: error || void 0,
|
|
2245
|
+
isSetup: isSetup && isFirstUser
|
|
2246
|
+
// Only show setup message if truly first user
|
|
2206
2247
|
};
|
|
2207
2248
|
return c.html(renderRegisterPage(pageData));
|
|
2208
2249
|
});
|
|
@@ -2248,7 +2289,7 @@ authRoutes.post(
|
|
|
2248
2289
|
if (existingUser) {
|
|
2249
2290
|
return c.json({ error: "User with this email or username already exists" }, 400);
|
|
2250
2291
|
}
|
|
2251
|
-
const passwordHash = await
|
|
2292
|
+
const passwordHash = await chunk7I5INVNR_cjs.AuthManager.hashPassword(password);
|
|
2252
2293
|
const userId = crypto.randomUUID();
|
|
2253
2294
|
const now = /* @__PURE__ */ new Date();
|
|
2254
2295
|
await db.prepare(`
|
|
@@ -2268,7 +2309,7 @@ authRoutes.post(
|
|
|
2268
2309
|
now.getTime(),
|
|
2269
2310
|
now.getTime()
|
|
2270
2311
|
).run();
|
|
2271
|
-
const token = await
|
|
2312
|
+
const token = await chunk7I5INVNR_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer");
|
|
2272
2313
|
cookie.setCookie(c, "auth_token", token, {
|
|
2273
2314
|
httpOnly: true,
|
|
2274
2315
|
secure: true,
|
|
@@ -2321,11 +2362,11 @@ authRoutes.post("/login", async (c) => {
|
|
|
2321
2362
|
if (!user) {
|
|
2322
2363
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2323
2364
|
}
|
|
2324
|
-
const isValidPassword = await
|
|
2365
|
+
const isValidPassword = await chunk7I5INVNR_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2325
2366
|
if (!isValidPassword) {
|
|
2326
2367
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2327
2368
|
}
|
|
2328
|
-
const token = await
|
|
2369
|
+
const token = await chunk7I5INVNR_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2329
2370
|
cookie.setCookie(c, "auth_token", token, {
|
|
2330
2371
|
httpOnly: true,
|
|
2331
2372
|
secure: true,
|
|
@@ -2374,7 +2415,7 @@ authRoutes.get("/logout", (c) => {
|
|
|
2374
2415
|
});
|
|
2375
2416
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
2376
2417
|
});
|
|
2377
|
-
authRoutes.get("/me",
|
|
2418
|
+
authRoutes.get("/me", chunk7I5INVNR_cjs.requireAuth(), async (c) => {
|
|
2378
2419
|
try {
|
|
2379
2420
|
const user = c.get("user");
|
|
2380
2421
|
if (!user) {
|
|
@@ -2391,13 +2432,13 @@ authRoutes.get("/me", chunkYHJB26RJ_cjs.requireAuth(), async (c) => {
|
|
|
2391
2432
|
return c.json({ error: "Failed to get user" }, 500);
|
|
2392
2433
|
}
|
|
2393
2434
|
});
|
|
2394
|
-
authRoutes.post("/refresh",
|
|
2435
|
+
authRoutes.post("/refresh", chunk7I5INVNR_cjs.requireAuth(), async (c) => {
|
|
2395
2436
|
try {
|
|
2396
2437
|
const user = c.get("user");
|
|
2397
2438
|
if (!user) {
|
|
2398
2439
|
return c.json({ error: "Not authenticated" }, 401);
|
|
2399
2440
|
}
|
|
2400
|
-
const token = await
|
|
2441
|
+
const token = await chunk7I5INVNR_cjs.AuthManager.generateToken(user.userId, user.email, user.role);
|
|
2401
2442
|
cookie.setCookie(c, "auth_token", token, {
|
|
2402
2443
|
httpOnly: true,
|
|
2403
2444
|
secure: true,
|
|
@@ -2457,7 +2498,7 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2457
2498
|
</div>
|
|
2458
2499
|
`);
|
|
2459
2500
|
}
|
|
2460
|
-
const passwordHash = await
|
|
2501
|
+
const passwordHash = await chunk7I5INVNR_cjs.AuthManager.hashPassword(password);
|
|
2461
2502
|
const role = isFirstUser ? "admin" : "viewer";
|
|
2462
2503
|
const userId = crypto.randomUUID();
|
|
2463
2504
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2477,7 +2518,10 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2477
2518
|
now.getTime(),
|
|
2478
2519
|
now.getTime()
|
|
2479
2520
|
).run();
|
|
2480
|
-
|
|
2521
|
+
if (isFirstUser) {
|
|
2522
|
+
setAdminExists();
|
|
2523
|
+
}
|
|
2524
|
+
const token = await chunk7I5INVNR_cjs.AuthManager.generateToken(userId, normalizedEmail, role);
|
|
2481
2525
|
cookie.setCookie(c, "auth_token", token, {
|
|
2482
2526
|
httpOnly: true,
|
|
2483
2527
|
secure: false,
|
|
@@ -2529,7 +2573,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2529
2573
|
</div>
|
|
2530
2574
|
`);
|
|
2531
2575
|
}
|
|
2532
|
-
const isValidPassword = await
|
|
2576
|
+
const isValidPassword = await chunk7I5INVNR_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2533
2577
|
if (!isValidPassword) {
|
|
2534
2578
|
return c.html(html.html`
|
|
2535
2579
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
|
|
@@ -2537,7 +2581,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2537
2581
|
</div>
|
|
2538
2582
|
`);
|
|
2539
2583
|
}
|
|
2540
|
-
const token = await
|
|
2584
|
+
const token = await chunk7I5INVNR_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2541
2585
|
cookie.setCookie(c, "auth_token", token, {
|
|
2542
2586
|
httpOnly: true,
|
|
2543
2587
|
secure: false,
|
|
@@ -2596,8 +2640,9 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2596
2640
|
`).run();
|
|
2597
2641
|
const existingAdmin = await db.prepare("SELECT id FROM users WHERE email = ? OR username = ?").bind("admin@sonicjs.com", "admin").first();
|
|
2598
2642
|
if (existingAdmin) {
|
|
2599
|
-
const passwordHash2 = await
|
|
2643
|
+
const passwordHash2 = await chunk7I5INVNR_cjs.AuthManager.hashPassword("sonicjs!");
|
|
2600
2644
|
await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(passwordHash2, Date.now(), existingAdmin.id).run();
|
|
2645
|
+
setAdminExists();
|
|
2601
2646
|
return c.json({
|
|
2602
2647
|
message: "Admin user already exists (password updated)",
|
|
2603
2648
|
user: {
|
|
@@ -2608,7 +2653,7 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2608
2653
|
}
|
|
2609
2654
|
});
|
|
2610
2655
|
}
|
|
2611
|
-
const passwordHash = await
|
|
2656
|
+
const passwordHash = await chunk7I5INVNR_cjs.AuthManager.hashPassword("sonicjs!");
|
|
2612
2657
|
const userId = "admin-user-id";
|
|
2613
2658
|
const now = Date.now();
|
|
2614
2659
|
const adminEmail = "admin@sonicjs.com".toLowerCase();
|
|
@@ -2628,6 +2673,7 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2628
2673
|
now,
|
|
2629
2674
|
now
|
|
2630
2675
|
).run();
|
|
2676
|
+
setAdminExists();
|
|
2631
2677
|
return c.json({
|
|
2632
2678
|
message: "Admin user created successfully",
|
|
2633
2679
|
user: {
|
|
@@ -2828,7 +2874,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2828
2874
|
if (existingUsername) {
|
|
2829
2875
|
return c.json({ error: "Username is already taken" }, 400);
|
|
2830
2876
|
}
|
|
2831
|
-
const passwordHash = await
|
|
2877
|
+
const passwordHash = await chunk7I5INVNR_cjs.AuthManager.hashPassword(password);
|
|
2832
2878
|
const updateStmt = db.prepare(`
|
|
2833
2879
|
UPDATE users SET
|
|
2834
2880
|
username = ?,
|
|
@@ -2847,7 +2893,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2847
2893
|
Date.now(),
|
|
2848
2894
|
invitedUser.id
|
|
2849
2895
|
).run();
|
|
2850
|
-
const authToken = await
|
|
2896
|
+
const authToken = await chunk7I5INVNR_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role);
|
|
2851
2897
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
2852
2898
|
httpOnly: true,
|
|
2853
2899
|
secure: true,
|
|
@@ -3077,7 +3123,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
3077
3123
|
if (Date.now() > user.password_reset_expires) {
|
|
3078
3124
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
3079
3125
|
}
|
|
3080
|
-
const newPasswordHash = await
|
|
3126
|
+
const newPasswordHash = await chunk7I5INVNR_cjs.AuthManager.hashPassword(password);
|
|
3081
3127
|
try {
|
|
3082
3128
|
const historyStmt = db.prepare(`
|
|
3083
3129
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
@@ -5979,7 +6025,7 @@ async function isPluginActive2(db, pluginId) {
|
|
|
5979
6025
|
|
|
5980
6026
|
// src/routes/admin-content.ts
|
|
5981
6027
|
var adminContentRoutes = new hono.Hono();
|
|
5982
|
-
adminContentRoutes.use("*",
|
|
6028
|
+
adminContentRoutes.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
5983
6029
|
async function getCollectionFields(db, collectionId) {
|
|
5984
6030
|
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.collection);
|
|
5985
6031
|
return cache.getOrSet(
|
|
@@ -8040,7 +8086,7 @@ function renderUserEditPage(data) {
|
|
|
8040
8086
|
<input
|
|
8041
8087
|
type="text"
|
|
8042
8088
|
name="first_name"
|
|
8043
|
-
value="${
|
|
8089
|
+
value="${chunkFYEDK7K7_cjs.escapeHtml(data.userToEdit.firstName || "")}"
|
|
8044
8090
|
required
|
|
8045
8091
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8046
8092
|
/>
|
|
@@ -8051,7 +8097,7 @@ function renderUserEditPage(data) {
|
|
|
8051
8097
|
<input
|
|
8052
8098
|
type="text"
|
|
8053
8099
|
name="last_name"
|
|
8054
|
-
value="${
|
|
8100
|
+
value="${chunkFYEDK7K7_cjs.escapeHtml(data.userToEdit.lastName || "")}"
|
|
8055
8101
|
required
|
|
8056
8102
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8057
8103
|
/>
|
|
@@ -8062,7 +8108,7 @@ function renderUserEditPage(data) {
|
|
|
8062
8108
|
<input
|
|
8063
8109
|
type="text"
|
|
8064
8110
|
name="username"
|
|
8065
|
-
value="${
|
|
8111
|
+
value="${chunkFYEDK7K7_cjs.escapeHtml(data.userToEdit.username || "")}"
|
|
8066
8112
|
required
|
|
8067
8113
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8068
8114
|
/>
|
|
@@ -8073,7 +8119,7 @@ function renderUserEditPage(data) {
|
|
|
8073
8119
|
<input
|
|
8074
8120
|
type="email"
|
|
8075
8121
|
name="email"
|
|
8076
|
-
value="${
|
|
8122
|
+
value="${chunkFYEDK7K7_cjs.escapeHtml(data.userToEdit.email || "")}"
|
|
8077
8123
|
required
|
|
8078
8124
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8079
8125
|
/>
|
|
@@ -8084,7 +8130,7 @@ function renderUserEditPage(data) {
|
|
|
8084
8130
|
<input
|
|
8085
8131
|
type="tel"
|
|
8086
8132
|
name="phone"
|
|
8087
|
-
value="${
|
|
8133
|
+
value="${chunkFYEDK7K7_cjs.escapeHtml(data.userToEdit.phone || "")}"
|
|
8088
8134
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8089
8135
|
/>
|
|
8090
8136
|
</div>
|
|
@@ -8098,7 +8144,7 @@ function renderUserEditPage(data) {
|
|
|
8098
8144
|
class="col-start-1 row-start-1 w-full appearance-none rounded-md bg-white/5 dark:bg-white/5 py-1.5 pl-3 pr-8 text-base text-zinc-950 dark:text-white outline outline-1 -outline-offset-1 outline-zinc-500/30 dark:outline-zinc-400/30 *:bg-white dark:*:bg-zinc-800 focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-zinc-500 dark:focus-visible:outline-zinc-400 sm:text-sm/6"
|
|
8099
8145
|
>
|
|
8100
8146
|
${data.roles.map((role) => `
|
|
8101
|
-
<option value="${
|
|
8147
|
+
<option value="${chunkFYEDK7K7_cjs.escapeHtml(role.value)}" ${data.userToEdit.role === role.value ? "selected" : ""}>${chunkFYEDK7K7_cjs.escapeHtml(role.label)}</option>
|
|
8102
8148
|
`).join("")}
|
|
8103
8149
|
</select>
|
|
8104
8150
|
<svg viewBox="0 0 16 16" fill="currentColor" data-slot="icon" aria-hidden="true" class="pointer-events-none col-start-1 row-start-1 mr-2 size-5 self-center justify-self-end text-zinc-600 dark:text-zinc-400 sm:size-4">
|
|
@@ -8114,7 +8160,7 @@ function renderUserEditPage(data) {
|
|
|
8114
8160
|
name="bio"
|
|
8115
8161
|
rows="3"
|
|
8116
8162
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8117
|
-
>${
|
|
8163
|
+
>${chunkFYEDK7K7_cjs.escapeHtml(data.userToEdit.bio || "")}</textarea>
|
|
8118
8164
|
</div>
|
|
8119
8165
|
</div>
|
|
8120
8166
|
|
|
@@ -9014,7 +9060,7 @@ function renderUsersListPage(data) {
|
|
|
9014
9060
|
|
|
9015
9061
|
// src/routes/admin-users.ts
|
|
9016
9062
|
var userRoutes = new hono.Hono();
|
|
9017
|
-
userRoutes.use("*",
|
|
9063
|
+
userRoutes.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
9018
9064
|
userRoutes.get("/", (c) => {
|
|
9019
9065
|
return c.redirect("/admin/dashboard");
|
|
9020
9066
|
});
|
|
@@ -9113,12 +9159,12 @@ userRoutes.put("/profile", async (c) => {
|
|
|
9113
9159
|
const db = c.env.DB;
|
|
9114
9160
|
try {
|
|
9115
9161
|
const formData = await c.req.formData();
|
|
9116
|
-
const firstName =
|
|
9117
|
-
const lastName =
|
|
9118
|
-
const username =
|
|
9162
|
+
const firstName = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9163
|
+
const lastName = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9164
|
+
const username = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9119
9165
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9120
|
-
const phone =
|
|
9121
|
-
const bio =
|
|
9166
|
+
const phone = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9167
|
+
const bio = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9122
9168
|
const timezone = formData.get("timezone")?.toString() || "UTC";
|
|
9123
9169
|
const language = formData.get("language")?.toString() || "en";
|
|
9124
9170
|
const emailNotifications = formData.get("email_notifications") === "1";
|
|
@@ -9169,7 +9215,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
9169
9215
|
Date.now(),
|
|
9170
9216
|
user.userId
|
|
9171
9217
|
).run();
|
|
9172
|
-
await
|
|
9218
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9173
9219
|
db,
|
|
9174
9220
|
user.userId,
|
|
9175
9221
|
"profile.update",
|
|
@@ -9232,7 +9278,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
9232
9278
|
SELECT first_name, last_name FROM users WHERE id = ?
|
|
9233
9279
|
`);
|
|
9234
9280
|
const userData = await userStmt.bind(user.userId).first();
|
|
9235
|
-
await
|
|
9281
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9236
9282
|
db,
|
|
9237
9283
|
user.userId,
|
|
9238
9284
|
"profile.avatar_update",
|
|
@@ -9303,7 +9349,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9303
9349
|
dismissible: true
|
|
9304
9350
|
}));
|
|
9305
9351
|
}
|
|
9306
|
-
const validPassword = await
|
|
9352
|
+
const validPassword = await chunk7I5INVNR_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
9307
9353
|
if (!validPassword) {
|
|
9308
9354
|
return c.html(renderAlert2({
|
|
9309
9355
|
type: "error",
|
|
@@ -9311,7 +9357,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9311
9357
|
dismissible: true
|
|
9312
9358
|
}));
|
|
9313
9359
|
}
|
|
9314
|
-
const newPasswordHash = await
|
|
9360
|
+
const newPasswordHash = await chunk7I5INVNR_cjs.AuthManager.hashPassword(newPassword);
|
|
9315
9361
|
const historyStmt = db.prepare(`
|
|
9316
9362
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
9317
9363
|
VALUES (?, ?, ?, ?)
|
|
@@ -9327,7 +9373,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9327
9373
|
WHERE id = ?
|
|
9328
9374
|
`);
|
|
9329
9375
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
9330
|
-
await
|
|
9376
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9331
9377
|
db,
|
|
9332
9378
|
user.userId,
|
|
9333
9379
|
"profile.password_change",
|
|
@@ -9394,7 +9440,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
9394
9440
|
`);
|
|
9395
9441
|
const countResult = await countStmt.bind(...params).first();
|
|
9396
9442
|
const totalUsers = countResult?.total || 0;
|
|
9397
|
-
await
|
|
9443
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9398
9444
|
db,
|
|
9399
9445
|
user.userId,
|
|
9400
9446
|
"users.list_view",
|
|
@@ -9496,12 +9542,12 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9496
9542
|
const user = c.get("user");
|
|
9497
9543
|
try {
|
|
9498
9544
|
const formData = await c.req.formData();
|
|
9499
|
-
const firstName =
|
|
9500
|
-
const lastName =
|
|
9501
|
-
const username =
|
|
9545
|
+
const firstName = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9546
|
+
const lastName = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9547
|
+
const username = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9502
9548
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9503
|
-
const phone =
|
|
9504
|
-
const bio =
|
|
9549
|
+
const phone = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9550
|
+
const bio = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9505
9551
|
const role = formData.get("role")?.toString() || "viewer";
|
|
9506
9552
|
const password = formData.get("password")?.toString() || "";
|
|
9507
9553
|
const confirmPassword = formData.get("confirm_password")?.toString() || "";
|
|
@@ -9548,7 +9594,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9548
9594
|
dismissible: true
|
|
9549
9595
|
}));
|
|
9550
9596
|
}
|
|
9551
|
-
const passwordHash = await
|
|
9597
|
+
const passwordHash = await chunk7I5INVNR_cjs.AuthManager.hashPassword(password);
|
|
9552
9598
|
const userId = crypto.randomUUID();
|
|
9553
9599
|
const createStmt = db.prepare(`
|
|
9554
9600
|
INSERT INTO users (
|
|
@@ -9571,7 +9617,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9571
9617
|
Date.now(),
|
|
9572
9618
|
Date.now()
|
|
9573
9619
|
).run();
|
|
9574
|
-
await
|
|
9620
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9575
9621
|
db,
|
|
9576
9622
|
user.userId,
|
|
9577
9623
|
"user!.create",
|
|
@@ -9609,7 +9655,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
9609
9655
|
if (!userRecord) {
|
|
9610
9656
|
return c.json({ error: "User not found" }, 404);
|
|
9611
9657
|
}
|
|
9612
|
-
await
|
|
9658
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9613
9659
|
db,
|
|
9614
9660
|
user.userId,
|
|
9615
9661
|
"user!.view",
|
|
@@ -9702,12 +9748,12 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
9702
9748
|
const userId = c.req.param("id");
|
|
9703
9749
|
try {
|
|
9704
9750
|
const formData = await c.req.formData();
|
|
9705
|
-
const firstName =
|
|
9706
|
-
const lastName =
|
|
9707
|
-
const username =
|
|
9751
|
+
const firstName = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9752
|
+
const lastName = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9753
|
+
const username = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9708
9754
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9709
|
-
const phone =
|
|
9710
|
-
const bio =
|
|
9755
|
+
const phone = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9756
|
+
const bio = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9711
9757
|
const role = formData.get("role")?.toString() || "viewer";
|
|
9712
9758
|
const isActive = formData.get("is_active") === "1";
|
|
9713
9759
|
const emailVerified = formData.get("email_verified") === "1";
|
|
@@ -9758,7 +9804,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
9758
9804
|
Date.now(),
|
|
9759
9805
|
userId
|
|
9760
9806
|
).run();
|
|
9761
|
-
await
|
|
9807
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9762
9808
|
db,
|
|
9763
9809
|
user.userId,
|
|
9764
9810
|
"user!.update",
|
|
@@ -9803,7 +9849,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
9803
9849
|
UPDATE users SET is_active = ?, updated_at = ? WHERE id = ?
|
|
9804
9850
|
`);
|
|
9805
9851
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
9806
|
-
await
|
|
9852
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9807
9853
|
db,
|
|
9808
9854
|
user.userId,
|
|
9809
9855
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -9844,7 +9890,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
9844
9890
|
DELETE FROM users WHERE id = ?
|
|
9845
9891
|
`);
|
|
9846
9892
|
await deleteStmt.bind(userId).run();
|
|
9847
|
-
await
|
|
9893
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9848
9894
|
db,
|
|
9849
9895
|
user.userId,
|
|
9850
9896
|
"user!.hard_delete",
|
|
@@ -9863,7 +9909,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
9863
9909
|
UPDATE users SET is_active = 0, updated_at = ? WHERE id = ?
|
|
9864
9910
|
`);
|
|
9865
9911
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
9866
|
-
await
|
|
9912
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9867
9913
|
db,
|
|
9868
9914
|
user.userId,
|
|
9869
9915
|
"user!.soft_delete",
|
|
@@ -9890,8 +9936,8 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
9890
9936
|
const formData = await c.req.formData();
|
|
9891
9937
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9892
9938
|
const role = formData.get("role")?.toString()?.trim() || "viewer";
|
|
9893
|
-
const firstName =
|
|
9894
|
-
const lastName =
|
|
9939
|
+
const firstName = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9940
|
+
const lastName = chunkFYEDK7K7_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9895
9941
|
if (!email || !firstName || !lastName) {
|
|
9896
9942
|
return c.json({ error: "Email, first name, and last name are required" }, 400);
|
|
9897
9943
|
}
|
|
@@ -9929,7 +9975,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
9929
9975
|
Date.now(),
|
|
9930
9976
|
Date.now()
|
|
9931
9977
|
).run();
|
|
9932
|
-
await
|
|
9978
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9933
9979
|
db,
|
|
9934
9980
|
user.userId,
|
|
9935
9981
|
"user!.invite_sent",
|
|
@@ -9986,7 +10032,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
9986
10032
|
Date.now(),
|
|
9987
10033
|
userId
|
|
9988
10034
|
).run();
|
|
9989
|
-
await
|
|
10035
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
9990
10036
|
db,
|
|
9991
10037
|
user.userId,
|
|
9992
10038
|
"user!.invitation_resent",
|
|
@@ -10022,7 +10068,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
10022
10068
|
}
|
|
10023
10069
|
const deleteStmt = db.prepare(`DELETE FROM users WHERE id = ?`);
|
|
10024
10070
|
await deleteStmt.bind(userId).run();
|
|
10025
|
-
await
|
|
10071
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
10026
10072
|
db,
|
|
10027
10073
|
user.userId,
|
|
10028
10074
|
"user!.invitation_cancelled",
|
|
@@ -10105,7 +10151,7 @@ userRoutes.get("/activity-logs", async (c) => {
|
|
|
10105
10151
|
...log,
|
|
10106
10152
|
details: log.details ? JSON.parse(log.details) : null
|
|
10107
10153
|
}));
|
|
10108
|
-
await
|
|
10154
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
10109
10155
|
db,
|
|
10110
10156
|
user.userId,
|
|
10111
10157
|
"activity.logs_viewed",
|
|
@@ -10212,7 +10258,7 @@ userRoutes.get("/activity-logs/export", async (c) => {
|
|
|
10212
10258
|
csvRows.push(row.join(","));
|
|
10213
10259
|
}
|
|
10214
10260
|
const csvContent = csvRows.join("\n");
|
|
10215
|
-
await
|
|
10261
|
+
await chunk7I5INVNR_cjs.logActivity(
|
|
10216
10262
|
db,
|
|
10217
10263
|
user.userId,
|
|
10218
10264
|
"activity.logs_exported",
|
|
@@ -11551,7 +11597,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
11551
11597
|
// 50MB max
|
|
11552
11598
|
});
|
|
11553
11599
|
var adminMediaRoutes = new hono.Hono();
|
|
11554
|
-
adminMediaRoutes.use("*",
|
|
11600
|
+
adminMediaRoutes.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
11555
11601
|
adminMediaRoutes.get("/", async (c) => {
|
|
11556
11602
|
try {
|
|
11557
11603
|
const user = c.get("user");
|
|
@@ -12137,7 +12183,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
12137
12183
|
`);
|
|
12138
12184
|
}
|
|
12139
12185
|
});
|
|
12140
|
-
adminMediaRoutes.delete("/cleanup",
|
|
12186
|
+
adminMediaRoutes.delete("/cleanup", chunk7I5INVNR_cjs.requireRole("admin"), async (c) => {
|
|
12141
12187
|
try {
|
|
12142
12188
|
const db = c.env.DB;
|
|
12143
12189
|
const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -13782,7 +13828,7 @@ function formatTimestamp(timestamp) {
|
|
|
13782
13828
|
|
|
13783
13829
|
// src/routes/admin-plugins.ts
|
|
13784
13830
|
var adminPluginRoutes = new hono.Hono();
|
|
13785
|
-
adminPluginRoutes.use("*",
|
|
13831
|
+
adminPluginRoutes.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
13786
13832
|
var AVAILABLE_PLUGINS = [
|
|
13787
13833
|
{
|
|
13788
13834
|
id: "third-party-faq",
|
|
@@ -15073,7 +15119,7 @@ function renderLogConfigPage(data) {
|
|
|
15073
15119
|
|
|
15074
15120
|
// src/routes/admin-logs.ts
|
|
15075
15121
|
var adminLogsRoutes = new hono.Hono();
|
|
15076
|
-
adminLogsRoutes.use("*",
|
|
15122
|
+
adminLogsRoutes.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
15077
15123
|
adminLogsRoutes.get("/", async (c) => {
|
|
15078
15124
|
try {
|
|
15079
15125
|
const user = c.get("user");
|
|
@@ -17401,9 +17447,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
17401
17447
|
}
|
|
17402
17448
|
|
|
17403
17449
|
// src/routes/admin-dashboard.ts
|
|
17404
|
-
var VERSION =
|
|
17450
|
+
var VERSION = chunkFYEDK7K7_cjs.getCoreVersion();
|
|
17405
17451
|
var router = new hono.Hono();
|
|
17406
|
-
router.use("*",
|
|
17452
|
+
router.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
17407
17453
|
router.get("/", async (c) => {
|
|
17408
17454
|
const user = c.get("user");
|
|
17409
17455
|
try {
|
|
@@ -19161,7 +19207,7 @@ function renderCollectionFormPage(data) {
|
|
|
19161
19207
|
|
|
19162
19208
|
// src/routes/admin-collections.ts
|
|
19163
19209
|
var adminCollectionsRoutes = new hono.Hono();
|
|
19164
|
-
adminCollectionsRoutes.use("*",
|
|
19210
|
+
adminCollectionsRoutes.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
19165
19211
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
19166
19212
|
try {
|
|
19167
19213
|
const user = c.get("user");
|
|
@@ -21324,7 +21370,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
21324
21370
|
|
|
21325
21371
|
// src/routes/admin-settings.ts
|
|
21326
21372
|
var adminSettingsRoutes = new hono.Hono();
|
|
21327
|
-
adminSettingsRoutes.use("*",
|
|
21373
|
+
adminSettingsRoutes.use("*", chunk7I5INVNR_cjs.requireAuth());
|
|
21328
21374
|
function getMockSettings(user) {
|
|
21329
21375
|
return {
|
|
21330
21376
|
general: {
|
|
@@ -21492,7 +21538,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
21492
21538
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
21493
21539
|
try {
|
|
21494
21540
|
const db = c.env.DB;
|
|
21495
|
-
const migrationService = new
|
|
21541
|
+
const migrationService = new chunk2MI3LZFH_cjs.MigrationService(db);
|
|
21496
21542
|
const status = await migrationService.getMigrationStatus();
|
|
21497
21543
|
return c.json({
|
|
21498
21544
|
success: true,
|
|
@@ -21516,7 +21562,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
21516
21562
|
}, 403);
|
|
21517
21563
|
}
|
|
21518
21564
|
const db = c.env.DB;
|
|
21519
|
-
const migrationService = new
|
|
21565
|
+
const migrationService = new chunk2MI3LZFH_cjs.MigrationService(db);
|
|
21520
21566
|
const result = await migrationService.runPendingMigrations();
|
|
21521
21567
|
return c.json({
|
|
21522
21568
|
success: result.success,
|
|
@@ -21534,7 +21580,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
21534
21580
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
21535
21581
|
try {
|
|
21536
21582
|
const db = c.env.DB;
|
|
21537
|
-
const migrationService = new
|
|
21583
|
+
const migrationService = new chunk2MI3LZFH_cjs.MigrationService(db);
|
|
21538
21584
|
const validation = await migrationService.validateSchema();
|
|
21539
21585
|
return c.json({
|
|
21540
21586
|
success: true,
|
|
@@ -21776,8 +21822,9 @@ exports.api_default = api_default;
|
|
|
21776
21822
|
exports.api_media_default = api_media_default;
|
|
21777
21823
|
exports.api_system_default = api_system_default;
|
|
21778
21824
|
exports.auth_default = auth_default;
|
|
21825
|
+
exports.checkAdminUserExists = checkAdminUserExists;
|
|
21779
21826
|
exports.router = router;
|
|
21780
21827
|
exports.test_cleanup_default = test_cleanup_default;
|
|
21781
21828
|
exports.userRoutes = userRoutes;
|
|
21782
|
-
//# sourceMappingURL=chunk-
|
|
21783
|
-
//# sourceMappingURL=chunk-
|
|
21829
|
+
//# sourceMappingURL=chunk-A4SVOGG6.cjs.map
|
|
21830
|
+
//# sourceMappingURL=chunk-A4SVOGG6.cjs.map
|