generated from Flycro/laravel-nuxt
feat: Add UserDeadline Relation
parent
fffe1b4717
commit
95ece0f614
|
|
@ -63,6 +63,11 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
return $this->hasMany(Vote::class);
|
return $this->hasMany(Vote::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deadlinesProgress()
|
||||||
|
{
|
||||||
|
return $this->hasMany(UserDeadline::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function mustVerifyEmail(): bool
|
public function mustVerifyEmail(): bool
|
||||||
{
|
{
|
||||||
return $this instanceof MustVerifyEmail && !$this->hasVerifiedEmail();
|
return $this instanceof MustVerifyEmail && !$this->hasVerifiedEmail();
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,60 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
definePageMeta({ middleware: ['guest'], layout: 'auth' })
|
definePageMeta({ middleware: ['guest'], layout: 'auth' })
|
||||||
|
|
||||||
const config = useRuntimeConfig();
|
const config = useRuntimeConfig()
|
||||||
const router = useRouter();
|
const router = useRouter()
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore()
|
||||||
const form = ref();
|
const form = ref()
|
||||||
|
|
||||||
type Provider = {
|
interface Provider {
|
||||||
name: string;
|
name: string
|
||||||
icon: string;
|
icon: string
|
||||||
color: string;
|
color: string
|
||||||
loading?: boolean;
|
loading?: boolean
|
||||||
};
|
}
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
email: "",
|
email: '',
|
||||||
password: "",
|
password: '',
|
||||||
remember: false,
|
remember: false,
|
||||||
});
|
})
|
||||||
|
|
||||||
const { refresh: onSubmit, status: loginStatus } = useFetch<any>("login", {
|
const { refresh: onSubmit, status: loginStatus } = useFetch<any>('login', {
|
||||||
method: "POST",
|
method: 'POST',
|
||||||
body: state,
|
body: state,
|
||||||
immediate: false,
|
immediate: false,
|
||||||
watch: false,
|
watch: false,
|
||||||
async onResponse({ response }) {
|
async onResponse({ response }) {
|
||||||
if (response?.status === 422) {
|
if (response?.status === 422) {
|
||||||
form.value.setErrors(response._data?.errors);
|
form.value.setErrors(response._data?.errors)
|
||||||
} else if (response._data?.ok) {
|
|
||||||
auth.token = response._data.token;
|
|
||||||
|
|
||||||
await auth.fetchUser();
|
|
||||||
await router.push("/");
|
|
||||||
}
|
}
|
||||||
}
|
else if (response._data?.ok) {
|
||||||
});
|
auth.token = response._data.token
|
||||||
|
|
||||||
const providers = ref<{ [key: string]: Provider }>(config.public.providers);
|
await auth.fetchUser()
|
||||||
|
await router.push('/')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const providers = ref<{ [key: string]: Provider }>(config.public.providers)
|
||||||
|
|
||||||
async function handleMessage(event: { data: any }): Promise<void> {
|
async function handleMessage(event: { data: any }): Promise<void> {
|
||||||
const provider = event.data.provider as string;
|
const provider = event.data.provider as string
|
||||||
|
|
||||||
if (Object.keys(providers.value).includes(provider) && event.data.token) {
|
if (Object.keys(providers.value).includes(provider) && event.data.token) {
|
||||||
providers.value[provider].loading = false;
|
providers.value[provider].loading = false
|
||||||
auth.token = event.data.token;
|
auth.token = event.data.token
|
||||||
|
|
||||||
await auth.fetchUser();
|
await auth.fetchUser()
|
||||||
await router.push("/");
|
await router.push('/')
|
||||||
} else if (event.data.message) {
|
}
|
||||||
|
else if (event.data.message) {
|
||||||
useToast().add({
|
useToast().add({
|
||||||
icon: "i-heroicons-exclamation-circle-solid",
|
icon: 'i-heroicons-exclamation-circle-solid',
|
||||||
color: "red",
|
color: 'red',
|
||||||
title: event.data.message,
|
title: event.data.message,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue