feat (auth): server side proxy login request

This commit is contained in:
Abizrh
2025-08-07 16:29:06 +07:00
parent d9bd19baaf
commit 2ecabaffb2
6 changed files with 101 additions and 40 deletions
+24 -5
View File
@@ -1,22 +1,41 @@
<script setup lang="ts">
// import PasswordInput from '~/components/PasswordInput.vue'
import { Loader2 } from 'lucide-vue-next'
const email = ref('demo@gmail.com')
const password = ref('password')
const isLoading = ref(false)
function onSubmit(event: Event) {
async function onSubmit(event: Event) {
event.preventDefault()
if (!email.value || !password.value) return
isLoading.value = true
setTimeout(() => {
if (email.value === 'demo@gmail.com' && password.value === 'password') navigateTo('/')
try {
const { data: respData } = await useFetch('/api/v1/authentication/login', {
method: 'POST',
body: JSON.stringify({
name: 'system',
password: 'the-SYSTEM-1234',
}),
})
const resp = respData.value
if (!resp) throw new Error('No response')
const { data: rawdata, meta } = resp
console.log('DATA', rawdata)
console.log('META', meta)
if (meta.status === 'verified') {
await nextTick()
navigateTo('/')
}
} catch (error) {
console.error('Login failed:', error)
} finally {
isLoading.value = false
}, 3000)
}
}
</script>