@opengis/fastify-table 2.4.13 → 2.4.15
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/server/plugins/logger/errorStatus.js +3 -3
- package/dist/server/routes/auth/controllers/2factor/verify.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/2factor/verify.js +8 -7
- package/dist/server/routes/auth/index.d.ts.map +1 -1
- package/dist/server/routes/auth/index.js +3 -0
- package/dist/server/templates/page/2factor.html +2 -2
- package/package.json +1 -1
|
@@ -7,13 +7,13 @@ function errorStatus(error) {
|
|
|
7
7
|
return 422;
|
|
8
8
|
}
|
|
9
9
|
if (error.routine === "exec_stmt_raise" && error.file === "pl_exec.c") {
|
|
10
|
-
return
|
|
10
|
+
return 422;
|
|
11
11
|
}
|
|
12
12
|
if (error.routine === "ExecConstraints") {
|
|
13
|
-
return
|
|
13
|
+
return 422;
|
|
14
14
|
}
|
|
15
15
|
if (error.type === "DatabaseError") {
|
|
16
|
-
return
|
|
16
|
+
return 500;
|
|
17
17
|
}
|
|
18
18
|
if (error.statusCode) {
|
|
19
19
|
return error.statusCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/2factor/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA2BvC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAA8B,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/2factor/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA2BvC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAA8B,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBA6DzE"}
|
|
@@ -31,9 +31,9 @@ const defaultPt = existsSync(path.join(dirname, `../../../../templates/pt/${temp
|
|
|
31
31
|
* @returns {String} redirect Шлях до переадресації
|
|
32
32
|
*/
|
|
33
33
|
export default async function verifyFunction(req, reply) {
|
|
34
|
-
const
|
|
34
|
+
const code = req.method === "POST" ? req.body?.code : req.query?.code;
|
|
35
|
+
const { pg = pgClients.client, user = {} } = req;
|
|
35
36
|
const { uid, twofa, email } = user || {};
|
|
36
|
-
const { code } = body;
|
|
37
37
|
if (!twofa) {
|
|
38
38
|
throw BadRequestError("2fa not enabled");
|
|
39
39
|
}
|
|
@@ -41,7 +41,7 @@ export default async function verifyFunction(req, reply) {
|
|
|
41
41
|
throw Error("empty pg");
|
|
42
42
|
}
|
|
43
43
|
if (!code) {
|
|
44
|
-
throw BadRequestError(
|
|
44
|
+
throw BadRequestError(`not enough ${req.method === "POST" ? "body" : "query"} params: code`);
|
|
45
45
|
}
|
|
46
46
|
const { enabled } = await verify({ uid, code, pg });
|
|
47
47
|
await enableSecret({ pg, uid });
|
|
@@ -67,8 +67,9 @@ export default async function verifyFunction(req, reply) {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
const redirectUrl = req.headers?.referer?.match?.(/[?&]redirect=([^&]+)/)?.[1] || "/";
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.status(200)
|
|
73
|
-
|
|
70
|
+
const safeRedirectUrl = redirectUrl.startsWith("/") ? redirectUrl : "/";
|
|
71
|
+
if (req.method === "POST") {
|
|
72
|
+
return reply.status(200).send({ redirectUrl: safeRedirectUrl });
|
|
73
|
+
}
|
|
74
|
+
return reply.redirect(safeRedirectUrl);
|
|
74
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"AA+CA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"AA+CA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QA+FtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -56,6 +56,9 @@ function plugin(app, opt = {}) {
|
|
|
56
56
|
}
|
|
57
57
|
// 2factor
|
|
58
58
|
if (!app.hasRoute({ method: "GET", url: "/2factor/verify" })) {
|
|
59
|
+
app.get("/2factor/verify", params, verify);
|
|
60
|
+
}
|
|
61
|
+
if (!app.hasRoute({ method: "POST", url: "/2factor/verify" })) {
|
|
59
62
|
app.post("/2factor/verify", params, verify);
|
|
60
63
|
}
|
|
61
64
|
if (!app.hasRoute({ method: "POST", url: "/2factor/recovery" })) {
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
Enter the 2-step verification code from your authenticator app.
|
|
66
66
|
</p>
|
|
67
67
|
|
|
68
|
-
<form action="/2factor/verify" method="
|
|
68
|
+
<form action="/2factor/verify" method="get">
|
|
69
69
|
<div class="space-y-5">
|
|
70
|
-
<div>
|
|
70
|
+
<div>
|
|
71
71
|
<input type="text" name="code" class="form-input hidden">
|
|
72
72
|
<div class="space-y-5">
|
|
73
73
|
<div class="my-3 flex gap-x-2" data-hs-pin-input>
|