Skip to content

Commit ac09617

Browse files
authored
Merge pull request #478 from devforth/feature/AdminForth/1193/i-think-we-had-some-feature-wh
fix: update Sidebar component to check for localhost instead of priva…
2 parents 0402ac9 + 17d94b8 commit ac09617

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

adminforth/modules/restApi.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,7 @@ 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)
387-
const clientIp = this.adminforth.auth.getClientIp(response.getHeaders?.() || {});
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-
}
394-
385+
395386
const publicPart = {
396387
brandName: this.adminforth.config.customization.brandName,
397388
usernameFieldName: usernameColumn.label,
@@ -421,7 +412,6 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
421412
userFullnameField: this.adminforth.config.auth.userFullNameField,
422413
settingPages: settingPages,
423414
defaultUserExists: defaultUserExists,
424-
isPrivateIP: isPrivateIP,
425415
}
426416

427417
// translate menu labels
@@ -1594,4 +1584,4 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
15941584
});
15951585

15961586
}
1597-
}
1587+
}

adminforth/spa/src/components/Sidebar.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</div>
5252
</div>
5353

54-
<div v-if="coreStore.config.defaultUserExists && !coreStore.config.isPrivateIP" class="p-4 mb-4 text-white rounded-lg bg-red-700/80 fill-white text-sm">
54+
<div v-if="coreStore.config.defaultUserExists && !isLocalhost" class="p-4 mb-4 text-white rounded-lg bg-red-700/80 fill-white text-sm">
5555
<IconExclamationCircleOutline class="inline-block align-text-bottom mr-0,5 w-5 h-5" />
5656
Default user <strong>"adminforth"</strong> detected. Delete it and create your own account.
5757
</div>
@@ -307,6 +307,8 @@ import type { AnnouncementBadgeResponse } from '@/types/Common';
307307
import { useAdminforth } from '@/adminforth';
308308
import { IconExclamationCircleOutline} from '@iconify-prerendered/vue-flowbite';
309309
310+
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' || window.location.hostname === '::1';
311+
310312
const { menu } = useAdminforth();
311313
312314
interface Props {

0 commit comments

Comments
 (0)