Skip to content

Commit b8ffdf9

Browse files
committed
fix: bind username and password inputs to reactive variables in LoginView
1 parent 4ee2cbd commit b8ffdf9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

adminforth/spa/src/views/LoginView.vue

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<div>
5050
<label for="username" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{ $t('Your') }} {{ coreStore.config?.usernameFieldName?.toLowerCase() }}</label>
5151
<Input
52+
v-model="username"
5253
autocomplete="username"
5354
type="username"
5455
name="username"
@@ -62,6 +63,7 @@
6263
<div class="">
6364
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{ $t('Your password') }}</label>
6465
<Input
66+
v-model="password"
6567
ref="passwordInput"
6668
autocomplete="current-password"
6769
oninput="setCustomValidity('')"
@@ -142,6 +144,8 @@ const { t } = useI18n();
142144
const passwordInput = ref(null);
143145
const usernameInput = ref(null);
144146
const rememberMeValue= ref(false);
147+
const username = ref('');
148+
const password = ref('');
145149
146150
const route = useRoute();
147151
const router = useRouter();
@@ -172,24 +176,21 @@ onBeforeMount(() => {
172176
173177
onMounted(async () => {
174178
if (coreStore.config?.demoCredentials) {
175-
const [username, password] = coreStore.config.demoCredentials.split(':');
176-
usernameInput.value.value = username;
177-
passwordInput.value.value = password;
179+
const [demoUsername, demoPassword] = coreStore.config.demoCredentials.split(':');
180+
username.value = demoUsername;
181+
password.value = demoPassword;
178182
}
179183
usernameInput.value.focus();
180184
});
181185
182186
183187
async function login() {
184188
185-
const username = usernameInput.value.value;
186-
const password = passwordInput.value.value;
187-
188-
if (!username) {
189+
if (!username.value) {
189190
usernameInput.value.setCustomValidity(t('Please fill out this field.'));
190191
return;
191192
}
192-
if (!password) {
193+
if (!password.value) {
193194
passwordInput.value.setCustomValidity(t('Please fill out this field.'));
194195
return;
195196
}
@@ -202,8 +203,8 @@ async function login() {
202203
path: '/login',
203204
method: 'POST',
204205
body: {
205-
username,
206-
password,
206+
username: username.value,
207+
password: password.value,
207208
rememberMe: rememberMeValue.value,
208209
}
209210
});

0 commit comments

Comments
 (0)