mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-24 21:54:04 +00:00
Rewrites resources/scripts/layouts/AuthLayout.vue from scratch using only the @theme tokens defined in themes.css and registered via @theme inline in invoiceshelf.css. The new layout is a centered card on the existing bg-glass-gradient utility, using the same visual vocabulary as BaseCard (bg-surface, rounded-xl, border-line-default, shadow-sm) so the auth pages read as a smaller, simpler version of the admin's existing card pattern. Both light and dark mode work automatically because every color references a theme token rather than a hardcoded hex/rgb. Drops the previous attempt's hardcoded #0a0e1a / #fbbf24 / #f5efe5 palette, the imported Google Fonts (Fraunces / Manrope / JetBrains Mono — replaced with the project default Poppins via font-base), the local --ink / --brass / --cream CSS variables that ignored [data-theme=dark], and the :deep() overrides that forced BaseInput / BaseButton into a custom underline style. The form components now render in the auth card identically to how they render anywhere else in the admin — same components, same theme tokens, no overrides. Removes four legacy SVG decorations from the original two-panel design: LoginPlanetCrater, LoginBackground, LoginBackgroundOverlay, LoginBottomVector. The page now has no decorative imagery — the bg-glass-gradient utility carries the visual mood. Adds w-full justify-center to the four auth-form submit buttons (LoginView, ForgotPasswordView, ResetPasswordView, RegisterWithInvitationView) so they fill the auth card width with their labels centered. Done at the call site rather than via :deep() so BaseButton stays untouched and the rest of the admin keeps its inline button style. Route-aware heading/subheading copy is preserved for all four auth views, and the four window.* admin customization hooks (login_page_logo, login_page_heading, login_page_description, copyright_text) still work.
136 lines
3.4 KiB
Vue
136 lines
3.4 KiB
Vue
<template>
|
|
<form id="loginForm" class="mt-12 text-left" @submit.prevent="onSubmit">
|
|
<BaseInputGroup
|
|
:error="v$.email.$error && v$.email.$errors[0].$message"
|
|
:label="$t('login.email')"
|
|
class="mb-4"
|
|
required
|
|
>
|
|
<BaseInput
|
|
v-model="authStore.loginData.email"
|
|
:invalid="v$.email.$error"
|
|
focus
|
|
type="email"
|
|
name="email"
|
|
@input="v$.email.$touch()"
|
|
/>
|
|
</BaseInputGroup>
|
|
|
|
<BaseInputGroup
|
|
:error="v$.password.$error && v$.password.$errors[0].$message"
|
|
:label="$t('login.password')"
|
|
class="mb-4"
|
|
required
|
|
>
|
|
<BaseInput
|
|
v-model="authStore.loginData.password"
|
|
:invalid="v$.password.$error"
|
|
:type="inputType"
|
|
name="password"
|
|
@input="v$.password.$touch()"
|
|
>
|
|
<template #right>
|
|
<BaseIcon
|
|
:name="isShowPassword ? 'EyeIcon' : 'EyeSlashIcon'"
|
|
class="mr-1 text-muted cursor-pointer"
|
|
@click="isShowPassword = !isShowPassword"
|
|
/>
|
|
</template>
|
|
</BaseInput>
|
|
</BaseInputGroup>
|
|
|
|
<div class="mt-5 mb-8">
|
|
<div class="mb-4">
|
|
<router-link
|
|
to="forgot-password"
|
|
class="text-sm text-primary-400 hover:text-body"
|
|
>
|
|
{{ $t('login.forgot_password') }}
|
|
</router-link>
|
|
</div>
|
|
</div>
|
|
|
|
<BaseButton :loading="isLoading" type="submit" class="w-full justify-center">
|
|
{{ $t('login.login') }}
|
|
</BaseButton>
|
|
</form>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, computed, onMounted } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
import { required, email, helpers } from '@vuelidate/validators'
|
|
import { useVuelidate } from '@vuelidate/core'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useAuthStore } from '../../../stores/auth.store'
|
|
import { useNotificationStore } from '../../../stores/notification.store'
|
|
|
|
declare global {
|
|
interface Window {
|
|
demo_mode?: boolean
|
|
}
|
|
}
|
|
|
|
const notificationStore = useNotificationStore()
|
|
const authStore = useAuthStore()
|
|
const { t } = useI18n()
|
|
const router = useRouter()
|
|
const isLoading = ref<boolean>(false)
|
|
const isShowPassword = ref<boolean>(false)
|
|
|
|
const rules = {
|
|
email: {
|
|
required: helpers.withMessage(t('validation.required'), required),
|
|
email: helpers.withMessage(t('validation.email_incorrect'), email),
|
|
},
|
|
password: {
|
|
required: helpers.withMessage(t('validation.required'), required),
|
|
},
|
|
}
|
|
|
|
const v$ = useVuelidate(
|
|
rules,
|
|
computed(() => authStore.loginData)
|
|
)
|
|
|
|
const inputType = computed<string>(() => {
|
|
return isShowPassword.value ? 'text' : 'password'
|
|
})
|
|
|
|
async function onSubmit(): Promise<void> {
|
|
v$.value.$touch()
|
|
|
|
if (v$.value.$invalid) {
|
|
return
|
|
}
|
|
|
|
isLoading.value = true
|
|
|
|
try {
|
|
await authStore.login(authStore.loginData)
|
|
|
|
router.push('/admin/dashboard')
|
|
|
|
notificationStore.showNotification({
|
|
type: 'success',
|
|
message: 'Logged in successfully.',
|
|
})
|
|
} catch (err: unknown) {
|
|
const { handleApiError } = await import('../../../utils/error-handling')
|
|
const normalized = handleApiError(err)
|
|
notificationStore.showNotification({
|
|
type: 'error',
|
|
message: normalized.message,
|
|
})
|
|
isLoading.value = false
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
if (window.demo_mode) {
|
|
authStore.loginData.email = 'demo@invoiceshelf.com'
|
|
authStore.loginData.password = 'demo'
|
|
}
|
|
})
|
|
</script>
|