Skip to content

Commit b467796

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents 08e2cb4 + f458a2c commit b467796

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

adminforth/spa/src/stores/core.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ export const useCoreStore = defineStore('core', () => {
198198
config.value = {...config.value, ...res};
199199
}
200200

201+
async function getLoginFormConfig() {
202+
const res = await callAdminForthApi({
203+
path: '/get_login_form_config',
204+
method: 'GET',
205+
});
206+
config.value = {...config.value, ...res};
207+
}
201208

202209
const username = computed(() => {
203210
const usernameField = config.value?.usernameField;
@@ -218,6 +225,7 @@ export const useCoreStore = defineStore('core', () => {
218225
userFullname,
219226
getPublicConfig,
220227
fetchMenuAndResource,
228+
getLoginFormConfig,
221229
fetchRecord,
222230
record,
223231
fetchResourceFull,

adminforth/spa/src/views/LoginView.vue

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@
9393
@update:disableLoginButton="setDisableLoginButton($event)"
9494
/>
9595

96-
<div v-if="loginPromptHTML"
96+
<div v-if="coreStore.config?.loginPromptHTML"
9797
class="flex items-center p-4 mb-4 text-sm text-lightLoginViewPromptText rounded-lg bg-lightLoginViewPromptBackground dark:bg-darkLoginViewPromptBackground dark:text-darkLoginViewPromptText" role="alert"
9898
>
9999
<svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
100100
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
101101
</svg>
102102
<span class="sr-only">{{ $t('Info') }}</span>
103-
<div v-html="loginPromptHTML"></div>
103+
<div v-html="coreStore.config?.loginPromptHTML"></div>
104104
</div>
105105
<Button @click="login" :loader="inProgress" :disabled="inProgress || disableLoginButton" class="w-full">
106106
{{ $t('Login to your account') }}
@@ -146,7 +146,6 @@ const password = ref('');
146146
const route = useRoute();
147147
const router = useRouter();
148148
const inProgress = ref(false);
149-
const loginPromptHTML = ref()
150149
const coreStore = useCoreStore();
151150
const user = useUserStore();
152151
@@ -160,14 +159,6 @@ const backgroundPosition = computed(() => {
160159
});
161160
162161
163-
async function getLoginFormConfig() {
164-
const response = await callAdminForthApi({
165-
path: '/get_login_form_config',
166-
method: 'GET',
167-
});
168-
loginPromptHTML.value = response.loginPromptHTML;
169-
}
170-
171162
onBeforeMount(() => {
172163
if (localStorage.getItem('isAuthorized') === 'true') {
173164
// if route has next param, redirect
@@ -181,7 +172,7 @@ onBeforeMount(() => {
181172
})
182173
183174
onMounted(async () => {
184-
getLoginFormConfig();
175+
coreStore.getLoginFormConfig();
185176
if (coreStore.config?.demoCredentials) {
186177
const [demoUsername, demoPassword] = coreStore.config.demoCredentials.split(':');
187178
username.value = demoUsername;

0 commit comments

Comments
 (0)