@opengis/fastify-table 2.0.84 → 2.0.85

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.
@@ -1 +1 @@
1
- {"version":3,"file":"authorizeUser.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/authorizeUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AA4BtD,wBAA8B,aAAa,CACzC,IAAI,EAAE,YAAY,EAClB,GAAG,EAAE,GAAG,EACR,QAAQ,SAAe,EACvB,MAAM,CAAC,EAAE,MAAM,gBA+HhB"}
1
+ {"version":3,"file":"authorizeUser.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/authorizeUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AA4BtD,wBAA8B,aAAa,CACzC,IAAI,EAAE,YAAY,EAClB,GAAG,EAAE,GAAG,EACR,QAAQ,SAAe,EACvB,MAAM,CAAC,EAAE,MAAM,gBA8HhB"}
@@ -57,7 +57,7 @@ export default async function authorizeUser(user, req, authType = "creds-user",
57
57
  {};
58
58
  await req.session?.save?.();
59
59
  const redirectUrl = req.headers?.referer?.match?.(/[?&]redirect=([^&]+)/)?.[1] || "/";
60
- const twofaEnabled = config.auth?.["2factor"] && user?.twofa && user.uid && pg;
60
+ const twofaEnabled = user?.twofa && user.uid && pg;
61
61
  const registered = false; // ? check by created/updated date?
62
62
  if (req.method === "POST" &&
63
63
  (!twofaEnabled || req.session?.secondFactorPassed)) {
@@ -91,7 +91,7 @@ export default async function authorizeUser(user, req, authType = "creds-user",
91
91
  }
92
92
  // by default, disable 2factor for id.gov.ua auth
93
93
  const check = authType === "govid" ? config.auth?.["2factor"]?.govid : true;
94
- if (config.auth?.["2factor"] && user?.twofa && check) {
94
+ if (user?.twofa && check) {
95
95
  return ("/2factor?redirect=" +
96
96
  (href ||
97
97
  config.auth?.redirectAfter ||
@@ -56,7 +56,7 @@ export async function onRequest(req, reply) {
56
56
  !config.auth?.disableRedirect &&
57
57
  !req.url.startsWith(prefix) &&
58
58
  !req.url.startsWith("/api") &&
59
- !req.url.startsWith(loginPageUrl) &&
59
+ !req.url.includes(loginPageUrl) &&
60
60
  !req.url.includes(".") &&
61
61
  !req.url.includes("@")) {
62
62
  return reply.redirect(`${loginPageUrl}` + `?redirect=${req.url}`);
@@ -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;AAiBvC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAA8B,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBAkEzE"}
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;AAiBvC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAA8B,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBAuEzE"}
@@ -28,10 +28,10 @@ const dirname = path.dirname(fileURLToPath(import.meta.url));
28
28
  */
29
29
  export default async function verifyFunction(req, reply) {
30
30
  const { pg = pgClients.client, session = {}, body = {} } = req;
31
- const { uid, email } = session?.passport?.user || {};
31
+ const { uid, twofa, email } = session?.passport?.user || {};
32
32
  // const { nocache = config.local } = query;
33
33
  const { code } = body;
34
- if (!config?.auth?.["2factor"]) {
34
+ if (!twofa) {
35
35
  return reply.status(400).send("2fa not enabled");
36
36
  }
37
37
  if (!config.pg) {
@@ -55,7 +55,7 @@ export default async function verifyFunction(req, reply) {
55
55
  ?.then((el) => el.rows?.[0] || {});
56
56
  const customPt = await getTemplate("pt", template);
57
57
  const pt = customPt ||
58
- (await readFile(path.join(dirname, `../../../../../templates/pt/${template}.html`), "utf8"));
58
+ (await readFile(path.join(dirname, `../../../../../templates/pt/${template}.hbs`), "utf8"));
59
59
  const html = await handlebars.compile(pt)({
60
60
  recoveryCodes,
61
61
  domain: `${req.protocol || "https"}://${req.hostname}`,
@@ -69,9 +69,15 @@ export default async function verifyFunction(req, reply) {
69
69
  });
70
70
  }
71
71
  const redirectUrl = req.headers?.referer?.match?.(/[?&]redirect=([^&]+)/)?.[1] || "/";
72
- return reply.redirect(redirectUrl.startsWith("/") ? redirectUrl : "/");
72
+ // return reply.redirect(redirectUrl.startsWith("/") ? redirectUrl : "/");
73
+ return reply
74
+ .status(200)
75
+ .send({ redirectUrl: redirectUrl.startsWith("/") ? redirectUrl : "/" });
73
76
  }
74
77
  catch (err) {
78
+ if (err.message === "Невірний код") {
79
+ return reply.status(401).send({ error: err.message, code: 401 });
80
+ }
75
81
  return reply.status(500).send(err.toString());
76
82
  }
77
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.84",
3
+ "version": "2.0.85",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [