create-nara 1.0.40 → 1.0.42
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.
Potentially problematic release.
This version of create-nara might be problematic. Click here for more details.
- package/package.json +1 -1
- package/templates/features/auth/app/middlewares/csrf.ts +2 -1
- package/templates/features/auth/app/middlewares/requestLogger.ts +5 -4
- package/templates/svelte/app/middlewares/csrf.ts +2 -1
- package/templates/svelte/app/middlewares/requestLogger.ts +5 -4
- package/templates/svelte/resources/js/pages/auth/login.svelte +8 -0
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { randomBytes } from 'crypto';
|
|
10
10
|
import type { NaraRequest, NaraResponse, NaraMiddleware } from '@nara-web/core';
|
|
11
11
|
import { jsonForbidden } from '@nara-web/core';
|
|
12
|
+
import Logger from '../services/Logger.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* CSRF configuration options
|
|
@@ -133,7 +134,7 @@ export function csrf(options: CSRFOptions = {}): NaraMiddleware {
|
|
|
133
134
|
|
|
134
135
|
// Validate token
|
|
135
136
|
if (!submittedToken || submittedToken !== token) {
|
|
136
|
-
|
|
137
|
+
Logger.logSecurity('CSRF validation failed', {
|
|
137
138
|
ip: req.ip,
|
|
138
139
|
path: req.path,
|
|
139
140
|
method: req.method,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { NaraRequest, NaraResponse, NaraMiddleware } from '@nara-web/core';
|
|
8
|
+
import Logger from '../services/Logger.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Request logger configuration options
|
|
@@ -142,13 +143,13 @@ export function requestLogger(options: RequestLoggerOptions = {}): NaraMiddlewar
|
|
|
142
143
|
|
|
143
144
|
// Log based on level
|
|
144
145
|
if (level === 'error') {
|
|
145
|
-
|
|
146
|
+
Logger.error(message, logData);
|
|
146
147
|
} else if (level === 'warn') {
|
|
147
|
-
|
|
148
|
+
Logger.warn(message, logData);
|
|
148
149
|
} else if (level === 'debug' || level === 'trace') {
|
|
149
|
-
|
|
150
|
+
Logger.debug(message, logData);
|
|
150
151
|
} else {
|
|
151
|
-
|
|
152
|
+
Logger.info(message, logData);
|
|
152
153
|
}
|
|
153
154
|
};
|
|
154
155
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { randomBytes } from 'crypto';
|
|
10
10
|
import type { NaraRequest, NaraResponse, NaraMiddleware } from '@nara-web/core';
|
|
11
11
|
import { jsonForbidden } from '@nara-web/core';
|
|
12
|
+
import Logger from '../services/Logger.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* CSRF configuration options
|
|
@@ -133,7 +134,7 @@ export function csrf(options: CSRFOptions = {}): NaraMiddleware {
|
|
|
133
134
|
|
|
134
135
|
// Validate token
|
|
135
136
|
if (!submittedToken || submittedToken !== token) {
|
|
136
|
-
|
|
137
|
+
Logger.logSecurity('CSRF validation failed', {
|
|
137
138
|
ip: req.ip,
|
|
138
139
|
path: req.path,
|
|
139
140
|
method: req.method,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { NaraRequest, NaraResponse, NaraMiddleware } from '@nara-web/core';
|
|
8
|
+
import Logger from '../services/Logger.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Request logger configuration options
|
|
@@ -142,13 +143,13 @@ export function requestLogger(options: RequestLoggerOptions = {}): NaraMiddlewar
|
|
|
142
143
|
|
|
143
144
|
// Log based on level
|
|
144
145
|
if (level === 'error') {
|
|
145
|
-
|
|
146
|
+
Logger.error(message, logData);
|
|
146
147
|
} else if (level === 'warn') {
|
|
147
|
-
|
|
148
|
+
Logger.warn(message, logData);
|
|
148
149
|
} else if (level === 'debug' || level === 'trace') {
|
|
149
|
-
|
|
150
|
+
Logger.debug(message, logData);
|
|
150
151
|
} else {
|
|
151
|
-
|
|
152
|
+
Logger.info(message, logData);
|
|
152
153
|
}
|
|
153
154
|
};
|
|
154
155
|
|
|
@@ -35,6 +35,14 @@
|
|
|
35
35
|
body: JSON.stringify({ email: form.email, password: form.password })
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
+
// Check if login was successful via redirect (backend returns 302 on success)
|
|
39
|
+
// fetch follows redirects automatically, so we check if we ended up at dashboard
|
|
40
|
+
if (response.redirected || response.url.endsWith('/dashboard')) {
|
|
41
|
+
Toast('Login successful', 'success');
|
|
42
|
+
router.visit('/dashboard');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
// Handle non-JSON responses (server errors returning HTML)
|
|
39
47
|
const contentType = response.headers.get('content-type');
|
|
40
48
|
if (!contentType || !contentType.includes('application/json')) {
|