Skip to content

Commit 45abeca

Browse files
committed
Merge branches 'next' and 'next' of github.com:devforth/adminforth into next
2 parents 6274ae9 + b9d2981 commit 45abeca

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

adminforth/modules/restApi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
109109
noAuth: true,
110110
method: 'POST',
111111
path: '/login',
112-
handler: async ({ body, response, headers, query, cookies, requestUrl }) => {
112+
handler: async ({ body, response, headers, query, cookies, requestUrl, tr }) => {
113113

114-
const INVALID_MESSAGE = 'Invalid Username or Password';
114+
const INVALID_MESSAGE = await tr('Invalid username or password', 'errors');
115115
const { username, password, rememberMe } = body;
116116
let adminUser: AdminUser;
117117
let toReturn: { redirectTo?: string, allowedLogin:boolean, error?: string } = { allowedLogin: true };
@@ -498,7 +498,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
498498
}
499499
const showIn = {} as ShowInResolved;
500500
await Promise.all(
501-
Object.entries(col.showIn).map(
501+
Object.entries(inCol.showIn).map(
502502
async ([key, value]: [string, AllowedActionValue]) => {
503503
// if callable then call
504504
if (typeof value === 'function') {

adminforth/spa/src/components/CustomDatePicker.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ watch(start, () => {
129129
})
130130
131131
function initDatepickers() {
132-
const options = {format: 'dd M yyyy'};
132+
const LS_LANG_KEY = `afLanguage`;
133+
const options = {format: 'dd M yyyy', language: localStorage.getItem(LS_LANG_KEY)};
133134
134135
if (props.autoHide) {
135136
options.autohide = true;

adminforth/spa/src/components/CustomDateRangePicker.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,9 @@ watch(end, () => {
184184
})
185185
186186
function initDatepickers() {
187-
188-
datepickerStartObject.value = new Datepicker(datepickerStartEl.value, {format: 'dd M yyyy'});
189-
190-
datepickerEndObject.value = new Datepicker(datepickerEndEl.value, {format: 'dd M yyyy'});
187+
const LS_LANG_KEY = `afLanguage`;
188+
datepickerStartObject.value = new Datepicker(datepickerStartEl.value, {format: 'dd M yyyy', language: localStorage.getItem(LS_LANG_KEY)});
189+
datepickerEndObject.value = new Datepicker(datepickerEndEl.value, {format: 'dd M yyyy', language: localStorage.getItem(LS_LANG_KEY)});
191190
addChangeDateListener();
192191
}
193192

adminforth/spa/src/views/LoginView.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
name="username"
4646
id="username"
4747
ref="usernameInput"
48+
oninput="setCustomValidity('')"
4849
@keydown.enter="passwordInput.focus()"
4950
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" placeholder="name@company.com" required />
5051
</div>
@@ -53,6 +54,7 @@
5354
<input
5455
ref="passwordInput"
5556
autocomplete="current-password"
57+
oninput="setCustomValidity('')"
5658
@keydown.enter="login"
5759
:type="!showPw ? 'password': 'text'" name="password" id="password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" required />
5860
<button type="button" @click="showPw = !showPw" class="absolute top-12 right-3 -translate-y-1/2 text-gray-400 dark:text-gray-300">
@@ -120,6 +122,9 @@ import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbi
120122
import { callAdminForthApi, loadFile } from '@/utils';
121123
import { useRoute, useRouter } from 'vue-router';
122124
import { Button, Checkbox } from '@/afcl';
125+
import { useI18n } from 'vue-i18n';
126+
127+
const { t } = useI18n();
123128
124129
const passwordInput = ref(null);
125130
const usernameInput = ref(null);
@@ -167,9 +172,15 @@ async function login() {
167172
const username = usernameInput.value.value;
168173
const password = passwordInput.value.value;
169174
170-
if (!username || !password) {
175+
if (!username) {
176+
usernameInput.value.setCustomValidity(t('Please fill out this field.'));
177+
return;
178+
}
179+
if (!password) {
180+
passwordInput.value.setCustomValidity(t('Please fill out this field.'));
171181
return;
172182
}
183+
173184
if (inProgress.value) {
174185
return;
175186
}
@@ -184,7 +195,7 @@ async function login() {
184195
}
185196
});
186197
if (resp.error) {
187-
error.value = resp.error;
198+
error.value = resp.error;
188199
} else if (resp.redirectTo) {
189200
router.push(resp.redirectTo);
190201
} else {

0 commit comments

Comments
 (0)