mirror of
https://github.com/YunoHost/yunohost-portal.git
synced 2024-09-03 20:06:23 +02:00
login: add login error
This commit is contained in:
parent
72527ad82a
commit
077fb2827a
2 changed files with 28 additions and 11 deletions
|
@ -33,6 +33,8 @@
|
||||||
"good_practices_about_user_password": "Pick a user password of at least 8 characters - though it is good practice to use longer ones (i.e. a passphrase) and/or use various kind of characters (uppercase, lowercase, digits and special characters).",
|
"good_practices_about_user_password": "Pick a user password of at least 8 characters - though it is good practice to use longer ones (i.e. a passphrase) and/or use various kind of characters (uppercase, lowercase, digits and special characters).",
|
||||||
"wrong_current_password": "The current password is wrong",
|
"wrong_current_password": "The current password is wrong",
|
||||||
"invalid_mail": "Invalid e-mail address",
|
"invalid_mail": "Invalid e-mail address",
|
||||||
|
"possibly_invalid_username": "Username is possibly invalid",
|
||||||
|
"possibly_invalid_password": "Password is possibly invalid",
|
||||||
"invalid_domain": "Invalid domain in",
|
"invalid_domain": "Invalid domain in",
|
||||||
"invalid_mailforward": "Invalid e-mail forwarding address",
|
"invalid_mailforward": "Invalid e-mail forwarding address",
|
||||||
"mail_already_used": "E-mail address already in use",
|
"mail_already_used": "E-mail address already in use",
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { useForm } from 'vee-validate'
|
||||||
|
import { toTypedSchema } from '@vee-validate/yup'
|
||||||
import * as yup from 'yup'
|
import * as yup from 'yup'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
|
@ -12,7 +14,16 @@ const head = useLocaleHead({
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const isLoggedIn = useIsLoggedIn()
|
const isLoggedIn = useIsLoggedIn()
|
||||||
|
|
||||||
async function login(form) {
|
const { handleSubmit, setErrors } = useForm({
|
||||||
|
validationSchema: toTypedSchema(
|
||||||
|
yup.object({
|
||||||
|
username: yup.string().required(),
|
||||||
|
password: yup.string().required(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
|
const login = handleSubmit(async (form) => {
|
||||||
const { error } = await useApi('/login', {
|
const { error } = await useApi('/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: { credentials: form.username + ':' + form.password },
|
body: { credentials: form.username + ':' + form.password },
|
||||||
|
@ -28,14 +39,12 @@ async function login(form) {
|
||||||
isLoggedIn.value = true
|
isLoggedIn.value = true
|
||||||
await navigateTo('/')
|
await navigateTo('/')
|
||||||
} else {
|
} else {
|
||||||
// FIXME : display an error or something
|
setErrors({
|
||||||
|
username: t('possibly_invalid_username'),
|
||||||
|
password: t('possibly_invalid_password'),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
const schema = {
|
|
||||||
username: yup.string().required(),
|
|
||||||
password: yup.string().required(),
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -46,7 +55,7 @@ const schema = {
|
||||||
src="/assets/img/logo-white.svg"
|
src="/assets/img/logo-white.svg"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<BaseForm :schema="schema" @submit="login">
|
<form novalidate @submit="login">
|
||||||
<FormField
|
<FormField
|
||||||
name="username"
|
name="username"
|
||||||
:label="t('username')"
|
:label="t('username')"
|
||||||
|
@ -54,7 +63,12 @@ const schema = {
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
row
|
row
|
||||||
>
|
>
|
||||||
<TextInput name="username" type="text" :placeholder="t('username')" />
|
<TextInput
|
||||||
|
name="username"
|
||||||
|
type="text"
|
||||||
|
:placeholder="t('username')"
|
||||||
|
autocomplete="username"
|
||||||
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
|
@ -68,11 +82,12 @@ const schema = {
|
||||||
name="password"
|
name="password"
|
||||||
type="password"
|
type="password"
|
||||||
:placeholder="t('password')"
|
:placeholder="t('password')"
|
||||||
|
autocomplete="current-password"
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<YButton :text="t('login')" type="submit" block />
|
<YButton :text="t('login')" type="submit" block />
|
||||||
</BaseForm>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue