Router guards: - apps/app: added DEV-gated logging matching admin pattern (route info, auth decisions, org selection, access granted/denied) - apps/portal: added DEV-gated logging matching admin pattern (route info, auth decisions, backward-compat redirects) - apps/admin: already had full logging (unchanged) Ungated console statements fixed: - admin/main.ts: error handler, plugin registration, mount errors - admin/pages/login.vue, register.vue: catch block errors - admin/pages/events/index.vue: fetch error logging - admin/pages/wizard-examples: demo form submit logging - admin/pages/faq.vue: catch block error All console statements in Crewli-authored code are now gated behind import.meta.env.DEV — zero console output in production builds. Vuexy template demo files (views/demos/*) left as-is. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
305 lines
8.8 KiB
Vue
305 lines
8.8 KiB
Vue
<script setup lang="ts">
|
|
import { VForm } from 'vuetify/components/VForm'
|
|
|
|
import AuthProvider from '@/views/pages/authentication/AuthProvider.vue'
|
|
import { VNodeRenderer } from '@layouts/components/VNodeRenderer'
|
|
import { themeConfig } from '@themeConfig'
|
|
import { getUserAbilityRules } from '@/utils/auth-ability'
|
|
import { useAuthStore } from '@/stores/useAuthStore'
|
|
import type { AuthUserCookie } from '@/composables/useOrganisationContext'
|
|
|
|
interface RegisterApiPayload {
|
|
success: boolean
|
|
data: {
|
|
user: AuthUserCookie & Record<string, unknown>
|
|
}
|
|
message?: string
|
|
}
|
|
|
|
import authV2RegisterIllustrationBorderedDark from '@images/pages/auth-v2-register-illustration-bordered-dark.png'
|
|
import authV2RegisterIllustrationBorderedLight from '@images/pages/auth-v2-register-illustration-bordered-light.png'
|
|
import authV2RegisterIllustrationDark from '@images/pages/auth-v2-register-illustration-dark.png'
|
|
import authV2RegisterIllustrationLight from '@images/pages/auth-v2-register-illustration-light.png'
|
|
import authV2MaskDark from '@images/pages/misc-mask-dark.png'
|
|
import authV2MaskLight from '@images/pages/misc-mask-light.png'
|
|
|
|
const imageVariant = useGenerateImageVariant(authV2RegisterIllustrationLight,
|
|
authV2RegisterIllustrationDark,
|
|
authV2RegisterIllustrationBorderedLight,
|
|
authV2RegisterIllustrationBorderedDark, true)
|
|
|
|
const authThemeMask = useGenerateImageVariant(authV2MaskLight, authV2MaskDark)
|
|
|
|
definePage({
|
|
meta: {
|
|
layout: 'blank',
|
|
unauthenticatedOnly: true,
|
|
},
|
|
})
|
|
|
|
const router = useRouter()
|
|
const ability = useAbility()
|
|
|
|
const form = ref({
|
|
name: '',
|
|
email: '',
|
|
password: '',
|
|
password_confirmation: '',
|
|
privacyPolicies: false,
|
|
})
|
|
|
|
const errors = ref<Record<string, string | undefined>>({
|
|
name: undefined,
|
|
email: undefined,
|
|
password: undefined,
|
|
})
|
|
|
|
const isPasswordVisible = ref(false)
|
|
const isLoading = ref(false)
|
|
const refVForm = ref<VForm>()
|
|
|
|
const register = async () => {
|
|
isLoading.value = true
|
|
try {
|
|
const res = await $api<RegisterApiPayload>('/auth/register', {
|
|
method: 'POST',
|
|
body: {
|
|
name: form.value.name,
|
|
email: form.value.email,
|
|
password: form.value.password,
|
|
password_confirmation: form.value.password_confirmation,
|
|
},
|
|
onResponseError({ response }) {
|
|
if (response._data?.errors) {
|
|
errors.value = {
|
|
name: response._data.errors.name?.[0],
|
|
email: response._data.errors.email?.[0],
|
|
password: response._data.errors.password?.[0],
|
|
}
|
|
}
|
|
else if (response._data?.message) {
|
|
errors.value = { email: response._data.message }
|
|
}
|
|
},
|
|
})
|
|
|
|
// Token is set automatically via httpOnly Set-Cookie header
|
|
const { data } = res
|
|
const userData = data.user
|
|
|
|
const roles = Array.isArray(userData.roles) ? userData.roles : []
|
|
const userAbilityRules = getUserAbilityRules(roles)
|
|
|
|
const authStore = useAuthStore()
|
|
authStore.setUser(userData, roles)
|
|
ability.update(userAbilityRules)
|
|
|
|
await nextTick(() => {
|
|
router.replace('/')
|
|
})
|
|
}
|
|
catch (err) {
|
|
if (import.meta.env.DEV) console.error(err)
|
|
}
|
|
finally {
|
|
isLoading.value = false
|
|
}
|
|
}
|
|
|
|
const onSubmit = () => {
|
|
refVForm.value?.validate()
|
|
.then(({ valid: isValid }) => {
|
|
if (isValid && form.value.privacyPolicies)
|
|
register()
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<RouterLink to="/">
|
|
<div class="auth-logo d-flex align-center gap-x-3">
|
|
<VNodeRenderer :nodes="themeConfig.app.logo" />
|
|
<h1 class="auth-title">
|
|
{{ themeConfig.app.title }}
|
|
</h1>
|
|
</div>
|
|
</RouterLink>
|
|
|
|
<VRow
|
|
no-gutters
|
|
class="auth-wrapper bg-surface"
|
|
>
|
|
<VCol
|
|
md="8"
|
|
class="d-none d-md-flex"
|
|
>
|
|
<div class="position-relative bg-background w-100 me-0">
|
|
<div
|
|
class="d-flex align-center justify-center w-100 h-100"
|
|
style="padding-inline: 100px;"
|
|
>
|
|
<VImg
|
|
max-width="500"
|
|
:src="imageVariant"
|
|
class="auth-illustration mt-16 mb-2"
|
|
/>
|
|
</div>
|
|
|
|
<img
|
|
class="auth-footer-mask"
|
|
:src="authThemeMask"
|
|
alt="auth-footer-mask"
|
|
height="280"
|
|
width="100"
|
|
>
|
|
</div>
|
|
</VCol>
|
|
|
|
<VCol
|
|
cols="12"
|
|
md="4"
|
|
class="auth-card-v2 d-flex align-center justify-center"
|
|
style="background-color: rgb(var(--v-theme-surface));"
|
|
>
|
|
<VCard
|
|
flat
|
|
:max-width="500"
|
|
class="mt-12 mt-sm-0 pa-4"
|
|
>
|
|
<VCardText>
|
|
<h4 class="text-h4 mb-1">
|
|
Adventure starts here 🚀
|
|
</h4>
|
|
<p class="mb-0">
|
|
Make your app management easy and fun!
|
|
</p>
|
|
</VCardText>
|
|
|
|
<VCardText>
|
|
<VForm
|
|
ref="refVForm"
|
|
@submit.prevent="onSubmit"
|
|
>
|
|
<VRow>
|
|
<!-- Name -->
|
|
<VCol cols="12">
|
|
<AppTextField
|
|
v-model="form.name"
|
|
:rules="[requiredValidator]"
|
|
:error-messages="errors.name"
|
|
autofocus
|
|
label="Full Name"
|
|
placeholder="John Doe"
|
|
/>
|
|
</VCol>
|
|
|
|
<!-- email -->
|
|
<VCol cols="12">
|
|
<AppTextField
|
|
v-model="form.email"
|
|
:rules="[requiredValidator, emailValidator]"
|
|
:error-messages="errors.email"
|
|
label="Email"
|
|
type="email"
|
|
placeholder="johndoe@email.com"
|
|
/>
|
|
</VCol>
|
|
|
|
<!-- password -->
|
|
<VCol cols="12">
|
|
<AppTextField
|
|
v-model="form.password"
|
|
:rules="[requiredValidator]"
|
|
:error-messages="errors.password"
|
|
label="Password"
|
|
placeholder="············"
|
|
:type="isPasswordVisible ? 'text' : 'password'"
|
|
autocomplete="new-password"
|
|
:append-inner-icon="isPasswordVisible ? 'tabler-eye-off' : 'tabler-eye'"
|
|
@click:append-inner="isPasswordVisible = !isPasswordVisible"
|
|
/>
|
|
</VCol>
|
|
|
|
<!-- confirm password -->
|
|
<VCol cols="12">
|
|
<AppTextField
|
|
v-model="form.password_confirmation"
|
|
:rules="[requiredValidator, confirmedValidator(form.password_confirmation, form.password)]"
|
|
label="Confirm Password"
|
|
placeholder="············"
|
|
:type="isPasswordVisible ? 'text' : 'password'"
|
|
autocomplete="new-password"
|
|
:append-inner-icon="isPasswordVisible ? 'tabler-eye-off' : 'tabler-eye'"
|
|
@click:append-inner="isPasswordVisible = !isPasswordVisible"
|
|
/>
|
|
|
|
<div class="d-flex align-center my-6">
|
|
<VCheckbox
|
|
id="privacy-policy"
|
|
v-model="form.privacyPolicies"
|
|
inline
|
|
/>
|
|
<VLabel
|
|
for="privacy-policy"
|
|
style="opacity: 1;"
|
|
>
|
|
<span class="me-1 text-high-emphasis">I agree to</span>
|
|
<a
|
|
href="javascript:void(0)"
|
|
class="text-primary"
|
|
>privacy policy & terms</a>
|
|
</VLabel>
|
|
</div>
|
|
|
|
<VBtn
|
|
block
|
|
type="submit"
|
|
:loading="isLoading"
|
|
:disabled="!form.privacyPolicies"
|
|
>
|
|
Sign up
|
|
</VBtn>
|
|
</VCol>
|
|
|
|
<!-- create account -->
|
|
<VCol
|
|
cols="12"
|
|
class="text-center text-base"
|
|
>
|
|
<span class="d-inline-block">Already have an account?</span>
|
|
<RouterLink
|
|
class="text-primary ms-1 d-inline-block"
|
|
:to="{ name: 'login' }"
|
|
>
|
|
Sign in instead
|
|
</RouterLink>
|
|
</VCol>
|
|
|
|
<VCol
|
|
cols="12"
|
|
class="d-flex align-center"
|
|
>
|
|
<VDivider />
|
|
<span class="mx-4">or</span>
|
|
<VDivider />
|
|
</VCol>
|
|
|
|
<!-- auth providers -->
|
|
<VCol
|
|
cols="12"
|
|
class="text-center"
|
|
>
|
|
<AuthProvider />
|
|
</VCol>
|
|
</VRow>
|
|
</VForm>
|
|
</VCardText>
|
|
</VCard>
|
|
</VCol>
|
|
</VRow>
|
|
</template>
|
|
|
|
<style lang="scss">
|
|
@use "@core/scss/template/pages/page-auth";
|
|
</style>
|