Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions adminforth/modules/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
}
}

let defaultUserExists = false;
if (username === 'adminforth') {
defaultUserExists = true;
}
const headers = response.getHeaders?.() || {};
const clientIp = this.adminforth.auth.getClientIp(headers);
const isPrivateIP = clientIp === null ? true :false;

const publicPart = {
brandName: this.adminforth.config.customization.brandName,
usernameFieldName: usernameColumn.label,
Expand Down Expand Up @@ -404,6 +412,8 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
globalInjections: this.adminforth.config.customization.globalInjections,
userFullnameField: this.adminforth.config.auth.userFullNameField,
settingPages: settingPages,
defaultUserExists: defaultUserExists,
isPrivateIP: isPrivateIP,
}

// translate menu labels
Expand Down
6 changes: 6 additions & 0 deletions adminforth/spa/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
</div>
</div>

<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">
<IconExclamationCircleOutline class="inline-block align-text-bottom mr-0,5 w-5 h-5" />
Default user <strong>"adminforth"</strong> detected. Delete it and create your own account.
</div>

<ul class="af-sidebar-container space-y-2 font-medium" >
<template v-if="!iconOnlySidebarEnabled || !isSidebarIconOnly" v-for="(item, i) in coreStore.menu" :key="`menu-${i}`">
<div v-if="item.type === 'divider'" class="border-t border-lightSidebarDevider dark:border-darkSidebarDevider"></div>
Expand Down Expand Up @@ -300,6 +305,7 @@ import { getIcon, verySimpleHash, loadFile, getCustomComponent } from '@/utils';
import { Tooltip } from '@/afcl';
import type { AnnouncementBadgeResponse } from '@/types/Common';
import { useAdminforth } from '@/adminforth';
import { IconExclamationCircleOutline} from '@iconify-prerendered/vue-flowbite';

const { menu } = useAdminforth();

Expand Down
1 change: 1 addition & 0 deletions adminforth/types/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,7 @@ export interface AdminForthConfigForFrontend {
loginBackgroundImage: string,
loginBackgroundPosition: string,
removeBackgroundBlendMode: boolean,
defaultUserExists?: boolean;
title?: string,
demoCredentials?: string,
loginPromptHTML?: string | (() => string | Promise<string> | void | Promise<void> | Promise<undefined>) | undefined
Expand Down