This commit is contained in:
@@ -1,13 +1,30 @@
|
||||
<template>
|
||||
<PrimeCard class="w-2/5">
|
||||
<PrimeCard>
|
||||
<template #content>
|
||||
<form class="flex flex-col gap-3" @submit.prevent="submit">
|
||||
<PrimeFloatLabel variant="on">
|
||||
<PrimeInputText id="username" v-model="localUsername" size="large" class="w-full" />
|
||||
<label for="username">Username</label>
|
||||
</PrimeFloatLabel>
|
||||
<form @submit.prevent="submit">
|
||||
<div class="flex flex-col gap-3">
|
||||
<PrimeFloatLabel variant="on">
|
||||
<PrimeInputText id="username" v-model="username" size="large" autocomplete="off" fluid autofocus />
|
||||
<label for="username">Username</label>
|
||||
</PrimeFloatLabel>
|
||||
|
||||
<PrimeButton size="large" icon="pi pi-arrow-right" icon-pos="right" label="Let's go" :disabled="!localUsername" type="submit" />
|
||||
<PrimeFloatLabel variant="on">
|
||||
<PrimePassword id="password" v-model="password" size="large" autocomplete="off" toggle-mask fluid :feedback="false" />
|
||||
<label for="password">Password</label>
|
||||
</PrimeFloatLabel>
|
||||
</div>
|
||||
|
||||
<PrimeButton
|
||||
class="mt-6"
|
||||
size="large"
|
||||
icon="pi pi-arrow-right"
|
||||
icon-pos="right"
|
||||
label="Let's go"
|
||||
:loading="submitting"
|
||||
:disabled="!valid"
|
||||
type="submit"
|
||||
fluid
|
||||
/>
|
||||
</form>
|
||||
</template>
|
||||
</PrimeCard>
|
||||
@@ -17,18 +34,34 @@
|
||||
definePageMeta({
|
||||
name: 'Login',
|
||||
layout: 'auth',
|
||||
auth: 'guest',
|
||||
})
|
||||
|
||||
const { username } = usePreferences()
|
||||
const { login } = useAuth()
|
||||
|
||||
const localUsername = ref<typeof username.value>()
|
||||
const submitting = ref(false)
|
||||
|
||||
const username = ref<string>()
|
||||
const password = ref<string>()
|
||||
|
||||
const valid = computed(() => {
|
||||
if (!username.value)
|
||||
return false
|
||||
|
||||
if (!password.value)
|
||||
return false
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
async function submit() {
|
||||
if (!localUsername.value)
|
||||
if (!valid.value)
|
||||
return
|
||||
|
||||
username.value = localUsername.value
|
||||
submitting.value = true
|
||||
|
||||
await navigateTo('/')
|
||||
await login(username.value!, password.value!)
|
||||
|
||||
submitting.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user