Files
mws.frontend.vue/src/views/auth/LoginView.vue
T

76 lines
2.5 KiB
Vue
Raw Normal View History

2026-08-11 23:17:04 +07:00
<template>
2026-08-24 08:07:23 +07:00
<div class="grid min-h-dvh lg:grid-cols-[1.05fr_1fr]">
2026-08-26 00:11:45 +07:00
<!-- Left panel: login image -->
<section class="brand-panel relative hidden overflow-hidden lg:flex lg:items-center lg:justify-center">
<img src="/login.png" alt="Login" class="absolute inset-0 h-full w-full object-cover" />
2026-09-14 21:24:59 +07:00
<h1 class="relative z-10 -mt-48 font-display text-5xl font-extrabold tracking-[-0.03em] text-white drop-shadow-lg">MY WORKSPACE</h1>
2026-08-24 08:07:23 +07:00
</section>
2026-09-14 21:24:59 +07:00
<section class="flex items-center justify-center p-6 sm:p-10" style="background: var(--canvas)">
2026-08-24 08:07:23 +07:00
<div class="w-full max-w-[360px]">
2026-09-14 21:24:59 +07:00
<div class="mb-8">
<span class="eyebrow">My Workspace</span>
2026-08-24 08:07:23 +07:00
<h2 class="page-title mt-2">Sign in</h2>
2026-09-14 21:24:59 +07:00
<p class="page-subtitle mt-2">Projects, documents and tasks in one place.</p>
2026-08-11 23:17:04 +07:00
</div>
2026-08-24 08:07:23 +07:00
2026-08-11 23:17:04 +07:00
<form @submit.prevent="submit">
<div class="field">
<label for="username">Username</label>
2026-08-24 08:07:23 +07:00
<InputText id="username" v-model.trim="username" class="w-full" autocomplete="username" autofocus />
2026-08-11 23:17:04 +07:00
</div>
<div class="field">
<label for="password">Password</label>
2026-08-24 08:07:23 +07:00
<Password
2026-08-11 23:17:04 +07:00
id="password"
v-model="password"
class="w-full"
2026-08-24 08:07:23 +07:00
inputClass="w-full"
toggleMask
:feedback="false"
2026-08-11 23:17:04 +07:00
autocomplete="current-password"
/>
</div>
2026-08-24 08:07:23 +07:00
<Message v-if="error" severity="error" variant="simple" class="mb-3 w-full">{{ error }}</Message>
2026-08-11 23:17:04 +07:00
<Button type="submit" label="Sign in" class="w-full" :loading="loading" />
</form>
2026-08-24 08:07:23 +07:00
</div>
</section>
2026-08-11 23:17:04 +07:00
</div>
</template>
<script setup lang="ts">
import { useAuthStore } from '../../stores/auth'
import { errorMessage } from '../../services/api'
const auth = useAuthStore()
const router = useRouter()
const route = useRoute()
const username = ref('')
const password = ref('')
const loading = ref(false)
const error = ref('')
async function submit() {
error.value = ''
if (!username.value || !password.value) {
2026-08-24 08:07:23 +07:00
error.value = 'Enter your username and password'
2026-08-11 23:17:04 +07:00
return
}
loading.value = true
try {
await auth.login(username.value, password.value)
2026-09-12 19:38:11 +07:00
const redirect = typeof route.query.redirect === 'string' ? route.query.redirect : null
router.push(redirect ?? (auth.isAdmin ? '/projects' : '/select-project'))
2026-08-11 23:17:04 +07:00
} catch (e) {
error.value = errorMessage(e)
} finally {
loading.value = false
}
}
</script>
2026-08-24 08:07:23 +07:00
<style scoped>
</style>