Skip to content

Commit 1a1da91

Browse files
committed
fix: correct detecting if user ip is private [2]
1 parent 366044b commit 1a1da91

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

adminforth/modules/restApi.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,15 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
382382
if (username === 'adminforth') {
383383
defaultUserExists = true;
384384
}
385+
386+
// getting client ip address (if null - ip definetely is private, if not null - check if it is private)
385387
const clientIp = this.adminforth.auth.getClientIp(response.getHeaders?.() || {});
386-
const isPrivateIP = is_ip_private(clientIp) === undefined || false ? true : false;
388+
let isPrivateIP = true;
389+
390+
if (clientIp) {
391+
// ip is not null, so we need to make sure that it is not private
392+
isPrivateIP = is_ip_private(clientIp);
393+
}
387394

388395
const publicPart = {
389396
brandName: this.adminforth.config.customization.brandName,

0 commit comments

Comments
 (0)