Skip to content

Commit 25866fa

Browse files
authored
Merge pull request #477 from devforth/feature/AdminForth/1193/i-think-we-had-some-feature-wh
fix: add is_ip_private function
2 parents 5785207 + b8c330d commit 25866fa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

adminforth/modules/restApi.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { ActionCheckSource, AdminForthConfigMenuItem, AdminForthDataTypes, Admin
2626
GetBaseConfigResponse,
2727
ShowInResolved} from "../types/Common.js";
2828
import { filtersTools } from "../modules/filtersTools.js";
29+
import is_ip_private from 'private-ip'
30+
2931

3032
async function resolveBoolOrFn(
3133
val: BackendOnlyInput | undefined,
@@ -381,7 +383,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
381383
defaultUserExists = true;
382384
}
383385
const clientIp = this.adminforth.auth.getClientIp(response.getHeaders?.() || {});
384-
const isPrivateIP = clientIp === null ? true : false;
386+
const isPrivateIP = is_ip_private(clientIp);
385387

386388
const publicPart = {
387389
brandName: this.adminforth.config.customization.brandName,
@@ -412,7 +414,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
412414
userFullnameField: this.adminforth.config.auth.userFullNameField,
413415
settingPages: settingPages,
414416
defaultUserExists: defaultUserExists,
415-
isPrivateIP: isPrivateIP,
417+
isPrivateIP: isPrivateIP,
416418
}
417419

418420
// translate menu labels

0 commit comments

Comments
 (0)