password.post.mjs
1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { e as eventHandler, r as readBody, C as updateMockSettingsPassword } from '../../../../nitro/nitro.mjs';
import { z } from 'zod';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';
import '@iconify/utils';
import 'consola';
const passwordPayloadSchema = z.object({
current: z.string().min(8),
new: z.string().min(8)
});
const password_post = eventHandler(async (event) => {
const body = await readBody(event);
const parsed = passwordPayloadSchema.safeParse(body);
if (!parsed.success) {
return {
success: false,
errorCode: "VALIDATION_ERROR",
message: "\u5BC6\u7801\u683C\u5F0F\u4E0D\u6B63\u786E\u3002"
};
}
if (parsed.data.current === parsed.data.new) {
return {
success: false,
errorCode: "VALIDATION_ERROR",
message: "\u65B0\u65E7\u5BC6\u7801\u4E0D\u80FD\u76F8\u540C\u3002"
};
}
const result = updateMockSettingsPassword(parsed.data.current, parsed.data.new);
if (!result.success) {
return result;
}
return result;
});
export { password_post as default };
//# sourceMappingURL=password.post.mjs.map