@opengis/fastify-table 2.5.41 → 2.5.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginUser.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/loginUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"loginUser.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/loginUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAuBvC,wBAA8B,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBA2DpE"}
|
|
@@ -4,9 +4,17 @@ import logger from "../../logger/getLogger.js";
|
|
|
4
4
|
import verifyPassword from "./verifyPassword.js";
|
|
5
5
|
import authorizeUser from "./authorizeUser.js";
|
|
6
6
|
import { BadRequestError } from "../../../../errors.js";
|
|
7
|
+
const getIp = (req) => (req.headers?.["x-real-ip"] ||
|
|
8
|
+
req.headers?.["x-forwarded-for"] ||
|
|
9
|
+
req.ip ||
|
|
10
|
+
req.connection?.remoteAddress ||
|
|
11
|
+
"")
|
|
12
|
+
.split(":")
|
|
13
|
+
.pop();
|
|
7
14
|
export default async function loginUser(req, reply) {
|
|
8
15
|
const { username, password } = (req.method === "POST" ? req.body : req.query) || {};
|
|
9
16
|
const { pg = pgClients.client } = req;
|
|
17
|
+
const ip = getIp(req);
|
|
10
18
|
if (!config.pg) {
|
|
11
19
|
if (req.method !== "GET") {
|
|
12
20
|
throw Error("empty pg");
|
|
@@ -29,6 +37,7 @@ export default async function loginUser(req, reply) {
|
|
|
29
37
|
password,
|
|
30
38
|
})) || {};
|
|
31
39
|
if (!user) {
|
|
40
|
+
logger.file("auth/warn", { error: message, username, ip });
|
|
32
41
|
if (req.method !== "GET") {
|
|
33
42
|
throw BadRequestError(message);
|
|
34
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyPassword.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/verifyPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"verifyPassword.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/verifyPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAYpD,wBAA8B,cAAc,CAAC,EAC3C,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;;;;;;eA6CA"}
|
|
@@ -15,8 +15,9 @@ export default async function verifyPassword({ pg, username, password, }) {
|
|
|
15
15
|
const json = await pg
|
|
16
16
|
.query(query, [username])
|
|
17
17
|
.then((r) => r.rows?.[0] || {});
|
|
18
|
-
if (!json)
|
|
18
|
+
if (!json) {
|
|
19
19
|
return { message: "user not found" };
|
|
20
|
+
}
|
|
20
21
|
if (json.password_new_hash_algorithm === true) {
|
|
21
22
|
const hash = await pg
|
|
22
23
|
.query(`SELECT public.crypt($1, $2)`, [password, json.salt])
|