@fuzionx/framework 0.1.45 → 0.1.46
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/core/Application.js +425 -138
- package/lib/core/Context.js +540 -236
- package/lib/middleware/auth.js +1 -1
- package/lib/middleware/csrf.js +1 -1
- package/lib/middleware/session.js +5 -4
- package/package.json +2 -2
package/lib/middleware/auth.js
CHANGED
|
@@ -16,7 +16,7 @@ export function auth(opts = {}) {
|
|
|
16
16
|
const redirectTo = opts.redirectTo || null;
|
|
17
17
|
|
|
18
18
|
return async (ctx, next) => {
|
|
19
|
-
const userId = ctx.
|
|
19
|
+
const userId = ctx._rawReq?.session?.[sessionKey] || ctx.get('x-test-user-id');
|
|
20
20
|
|
|
21
21
|
if (!userId) {
|
|
22
22
|
if (redirectTo) {
|
package/lib/middleware/csrf.js
CHANGED
|
@@ -20,7 +20,7 @@ export function csrf(opts = {}) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const token = ctx.get(headerName);
|
|
23
|
-
const expected = ctx.
|
|
23
|
+
const expected = ctx._rawReq?.session?.[sessionKey];
|
|
24
24
|
|
|
25
25
|
if (!token || !expected || token !== expected) {
|
|
26
26
|
ctx.status(403).json({ error: { message: 'CSRF token mismatch', status: 403 } });
|
|
@@ -15,12 +15,13 @@ export function session(opts = {}) {
|
|
|
15
15
|
// 요청 완료 후 — 소비된 flash 데이터 정리
|
|
16
16
|
const bridge = ctx.app?._bridge;
|
|
17
17
|
const sessionId = ctx._sessionId;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const rawSession = ctx._rawReq?.session;
|
|
19
|
+
if (sessionId && bridge?.sessionSet && rawSession) {
|
|
20
|
+
if (rawSession._flash && Object.keys(rawSession._flash).length === 0) {
|
|
21
|
+
delete rawSession._flash;
|
|
21
22
|
}
|
|
22
23
|
try {
|
|
23
|
-
bridge.sessionSet(sessionId,
|
|
24
|
+
bridge.sessionSet(sessionId, rawSession);
|
|
24
25
|
} catch {}
|
|
25
26
|
}
|
|
26
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuzionx/framework",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.46",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Full-stack MVC framework built on @fuzionx/core — Controller, Service, Model, Middleware, DI, EventBus",
|
|
6
6
|
"main": "index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"url": "https://github.com/saytohenry/fuzionx"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@fuzionx/core": "^0.1.
|
|
37
|
+
"@fuzionx/core": "^0.1.46",
|
|
38
38
|
"better-sqlite3": "^12.8.0",
|
|
39
39
|
"knex": "^3.2.5",
|
|
40
40
|
"mongoose": "^9.3.2",
|