mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +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.
170 lines
3.9 KiB
Vue
170 lines
3.9 KiB
Vue
<template>
|
|
<form id="loginForm" @submit.prevent="onSubmit">
|
|
<BaseInputGroup
|
|
:error="errorEmail"
|
|
:label="$t('login.email')"
|
|
class="mb-4"
|
|
required
|
|
>
|
|
<BaseInput
|
|
v-model="formData.email"
|
|
:invalid="v$.email.$error"
|
|
focus
|
|
type="email"
|
|
name="email"
|
|
@input="v$.email.$touch()"
|
|
/>
|
|
</BaseInputGroup>
|
|
|
|
<BaseInputGroup
|
|
:error="errorPassword"
|
|
:label="$t('login.password')"
|
|
class="mb-4"
|
|
required
|
|
>
|
|
<BaseInput
|
|
v-model="formData.password"
|
|
:invalid="v$.password.$error"
|
|
type="password"
|
|
name="password"
|
|
@input="v$.password.$touch()"
|
|
/>
|
|
</BaseInputGroup>
|
|
|
|
<BaseInputGroup
|
|
:error="errorConfirmPassword"
|
|
:label="$t('login.retype_password')"
|
|
class="mb-4"
|
|
required
|
|
>
|
|
<BaseInput
|
|
v-model="formData.password_confirmation"
|
|
:invalid="v$.password_confirmation.$error"
|
|
type="password"
|
|
name="password_confirmation"
|
|
@input="v$.password_confirmation.$touch()"
|
|
/>
|
|
</BaseInputGroup>
|
|
|
|
<BaseButton :loading="isLoading" type="submit" variant="primary" class="w-full justify-center">
|
|
{{ $t('login.reset_password') }}
|
|
</BaseButton>
|
|
</form>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, computed, reactive } from 'vue'
|
|
import useVuelidate from '@vuelidate/core'
|
|
import { required, email, minLength, sameAs } from '@vuelidate/validators'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useAuthStore } from '../../../stores/auth.store'
|
|
import { useNotificationStore } from '../../../stores/notification.store'
|
|
import { handleApiError } from '../../../utils/error-handling'
|
|
|
|
interface ResetPasswordForm {
|
|
email: string
|
|
password: string
|
|
password_confirmation: string
|
|
}
|
|
|
|
const notificationStore = useNotificationStore()
|
|
const authStore = useAuthStore()
|
|
const { t } = useI18n()
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
|
|
const formData = reactive<ResetPasswordForm>({
|
|
email: '',
|
|
password: '',
|
|
password_confirmation: '',
|
|
})
|
|
|
|
const isLoading = ref<boolean>(false)
|
|
|
|
const rules = computed(() => ({
|
|
email: { required, email },
|
|
password: {
|
|
required,
|
|
minLength: minLength(8),
|
|
},
|
|
password_confirmation: {
|
|
sameAsPassword: sameAs(formData.password),
|
|
},
|
|
}))
|
|
|
|
const v$ = useVuelidate(rules, formData)
|
|
|
|
const errorEmail = computed<string>(() => {
|
|
if (!v$.value.email.$error) {
|
|
return ''
|
|
}
|
|
if (v$.value.email.required.$invalid) {
|
|
return t('validation.required')
|
|
}
|
|
if (v$.value.email.email) {
|
|
return t('validation.email_incorrect')
|
|
}
|
|
return ''
|
|
})
|
|
|
|
const errorPassword = computed<string>(() => {
|
|
if (!v$.value.password.$error) {
|
|
return ''
|
|
}
|
|
if (v$.value.password.required.$invalid) {
|
|
return t('validation.required')
|
|
}
|
|
if (v$.value.password.minLength) {
|
|
return t('validation.password_min_length', {
|
|
count: v$.value.password.minLength.$params.min,
|
|
})
|
|
}
|
|
return ''
|
|
})
|
|
|
|
const errorConfirmPassword = computed<string>(() => {
|
|
if (!v$.value.password_confirmation.$error) {
|
|
return ''
|
|
}
|
|
if (v$.value.password_confirmation.sameAsPassword.$invalid) {
|
|
return t('validation.password_incorrect')
|
|
}
|
|
return ''
|
|
})
|
|
|
|
async function onSubmit(): Promise<void> {
|
|
v$.value.$touch()
|
|
|
|
if (v$.value.$invalid) {
|
|
return
|
|
}
|
|
|
|
try {
|
|
isLoading.value = true
|
|
|
|
await authStore.resetPassword({
|
|
email: formData.email,
|
|
password: formData.password,
|
|
password_confirmation: formData.password_confirmation,
|
|
token: route.params.token as string,
|
|
})
|
|
|
|
notificationStore.showNotification({
|
|
type: 'success',
|
|
message: t('login.password_reset_successfully'),
|
|
})
|
|
|
|
router.push('/login')
|
|
} catch (err: unknown) {
|
|
const normalized = handleApiError(err)
|
|
notificationStore.showNotification({
|
|
type: 'error',
|
|
message: normalized.message,
|
|
})
|
|
} finally {
|
|
isLoading.value = false
|
|
}
|
|
}
|
|
</script>
|