Skip to content
Merged
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
4 changes: 2 additions & 2 deletions adminforth/modules/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
noAuth: true,
method: 'POST',
path: '/login',
handler: async ({ body, response, headers, query, cookies, requestUrl }) => {
handler: async ({ body, response, headers, query, cookies, requestUrl, tr }) => {

const INVALID_MESSAGE = 'Invalid Username or Password';
const INVALID_MESSAGE = await tr('Invalid username or password', 'errors');
const { username, password, rememberMe } = body;
let adminUser: AdminUser;
let toReturn: { redirectTo?: string, allowedLogin:boolean, error?: string } = { allowedLogin: true };
Expand Down
3 changes: 2 additions & 1 deletion adminforth/spa/src/components/CustomDatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ watch(start, () => {
})

function initDatepickers() {
const options = {format: 'dd M yyyy'};
const LS_LANG_KEY = `afLanguage`;
const options = {format: 'dd M yyyy', language: localStorage.getItem(LS_LANG_KEY)};

if (props.autoHide) {
options.autohide = true;
Expand Down
7 changes: 3 additions & 4 deletions adminforth/spa/src/components/CustomDateRangePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,9 @@ watch(end, () => {
})

function initDatepickers() {

datepickerStartObject.value = new Datepicker(datepickerStartEl.value, {format: 'dd M yyyy'});

datepickerEndObject.value = new Datepicker(datepickerEndEl.value, {format: 'dd M yyyy'});
const LS_LANG_KEY = `afLanguage`;
datepickerStartObject.value = new Datepicker(datepickerStartEl.value, {format: 'dd M yyyy', language: localStorage.getItem(LS_LANG_KEY)});
datepickerEndObject.value = new Datepicker(datepickerEndEl.value, {format: 'dd M yyyy', language: localStorage.getItem(LS_LANG_KEY)});
addChangeDateListener();
}

Expand Down
15 changes: 13 additions & 2 deletions adminforth/spa/src/views/LoginView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
name="username"
id="username"
ref="usernameInput"
oninput="setCustomValidity('')"
@keydown.enter="passwordInput.focus()"
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 />
</div>
Expand All @@ -53,6 +54,7 @@
<input
ref="passwordInput"
autocomplete="current-password"
oninput="setCustomValidity('')"
@keydown.enter="login"
: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 />
<button type="button" @click="showPw = !showPw" class="absolute top-12 right-3 -translate-y-1/2 text-gray-400 dark:text-gray-300">
Expand Down Expand Up @@ -120,6 +122,9 @@ import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbi
import { callAdminForthApi, loadFile } from '@/utils';
import { useRoute, useRouter } from 'vue-router';
import { Button, Checkbox } from '@/afcl';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const passwordInput = ref(null);
const usernameInput = ref(null);
Expand Down Expand Up @@ -167,9 +172,15 @@ async function login() {
const username = usernameInput.value.value;
const password = passwordInput.value.value;

if (!username || !password) {
if (!username) {
usernameInput.value.setCustomValidity(t('Please fill out this field.'));
return;
}
if (!password) {
passwordInput.value.setCustomValidity(t('Please fill out this field.'));
return;
}

if (inProgress.value) {
return;
}
Expand All @@ -184,7 +195,7 @@ async function login() {
}
});
if (resp.error) {
error.value = resp.error;
error.value = resp.error;
} else if (resp.redirectTo) {
router.push(resp.redirectTo);
} else {
Expand Down