@plutocms/supabase 0.0.1-alpha.10 → 0.0.1-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,8 @@ interface PlutoSupabaseAuthOptions {
5
5
  }
6
6
 
7
7
  export async function useAuth(authOptions?: PlutoSupabaseAuthOptions) {
8
+ const toast = useToast()
9
+
8
10
  const supabase = useSupabaseClient()
9
11
  const supabaseSession = useSupabaseSession()
10
12
 
@@ -31,6 +33,13 @@ export async function useAuth(authOptions?: PlutoSupabaseAuthOptions) {
31
33
  if (error) {
32
34
  console.error(`Error signing in user: ${error?.message}`)
33
35
 
36
+ toast.add({
37
+ title: 'Could not log in',
38
+ description: error?.message,
39
+ icon: 'lucide:circle-x',
40
+ color: 'error',
41
+ })
42
+
34
43
  isSubmitting.value = false
35
44
 
36
45
  return
@@ -76,6 +85,12 @@ export async function useAuth(authOptions?: PlutoSupabaseAuthOptions) {
76
85
 
77
86
  if (options?.showToast) {
78
87
  console.warn(`User logged out`)
88
+
89
+ toast.add({
90
+ title: 'Logged out successfully',
91
+ icon: 'lucide:check',
92
+ color: 'success',
93
+ })
79
94
  }
80
95
 
81
96
  if (options?.redirectTo) {
@@ -19,6 +19,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
19
19
  if (
20
20
  !isLoggedIn.value &&
21
21
  to.path.startsWith('/admin') &&
22
+ to.path !== '/admin/confirm' &&
22
23
  to.path !== '/admin/signup' &&
23
24
  to.path !== '/admin/login'
24
25
  ) {
@@ -0,0 +1,38 @@
1
+ <script setup lang="ts">
2
+ definePageMeta({
3
+ layout: 'auth',
4
+ })
5
+
6
+ useHead({
7
+ title: 'Account Verification',
8
+ })
9
+ </script>
10
+
11
+ <template>
12
+ <div class="grid h-full place-items-center">
13
+ <UCard class="w-100">
14
+ <div class="space-y-6 py-10">
15
+ <div class="text-center space-y-4">
16
+ <hgroup class="flex flex-col gap-y-1">
17
+ <span class="text-5xl">
18
+ <UIcon name="lucide:mail-check" class="inline-block" />
19
+ </span>
20
+
21
+ <h1 class="text-3xl font-bold">Account verified!</h1>
22
+ </hgroup>
23
+
24
+ <p>
25
+ Your account has been successfully verified. You can now start using
26
+ the Dashboard.
27
+ </p>
28
+
29
+ <div class="flex items-center justify-center gap-x-4">
30
+ <UButton to="/admin" color="primary" icon="lucide:layout-dashboard">
31
+ Go to Dashboard
32
+ </UButton>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </UCard>
37
+ </div>
38
+ </template>
@@ -7,6 +7,8 @@ useHead({
7
7
  title: 'Sign Up',
8
8
  })
9
9
 
10
+ const toast = useToast()
11
+
10
12
  const form = ref({
11
13
  email: '',
12
14
  username: '',
@@ -21,12 +23,15 @@ const passwordMatch = computed(() => {
21
23
  return form.value.password === form.value.confirm_password
22
24
  })
23
25
 
26
+ const isEmailVerificationMessageVisible = ref<boolean>(false)
27
+
24
28
  async function submitForm() {
25
29
  if (!passwordMatch.value) {
26
30
  return
27
31
  }
28
32
 
29
33
  isSubmitting.value = true
34
+
30
35
  try {
31
36
  await $fetch('/api/signup', {
32
37
  method: 'POST',
@@ -38,9 +43,24 @@ async function submitForm() {
38
43
  },
39
44
  })
40
45
 
41
- navigateTo('/admin/login?rel=new')
46
+ toast.add({
47
+ title: 'Account created successfully',
48
+ description: 'You still need to verify your email before you can log in.',
49
+ icon: 'lucide:check',
50
+ color: 'success',
51
+ })
52
+
53
+ isEmailVerificationMessageVisible.value = true
42
54
  } catch (error) {
43
55
  console.error('Error signing up:', error)
56
+
57
+ toast.add({
58
+ title: 'Could not create account',
59
+ description:
60
+ error instanceof Error ? error.message : 'An unknown error occurred.',
61
+ icon: 'lucide:circle-x',
62
+ color: 'error',
63
+ })
44
64
  } finally {
45
65
  isSubmitting.value = false
46
66
  }
@@ -50,11 +70,45 @@ async function submitForm() {
50
70
  <template>
51
71
  <div class="grid h-full place-items-center">
52
72
  <UCard class="w-100">
53
- <form @submit.prevent="submitForm">
73
+ <div v-if="isEmailVerificationMessageVisible" class="space-y-6 py-10">
74
+ <div class="text-center space-y-4">
75
+ <hgroup class="flex flex-col gap-y-1">
76
+ <span class="text-5xl">
77
+ <UIcon name="lucide:mail-warning" class="inline-block" />
78
+ </span>
79
+
80
+ <h1 class="text-3xl font-bold">Almost there!</h1>
81
+ </hgroup>
82
+
83
+ <p>
84
+ A verification link has been sent to your email. Please check your
85
+ inbox and follow the instructions to verify your account.
86
+ </p>
87
+
88
+ <UAlert icon="lucide:check" color="success" variant="outline">
89
+ <template #description>
90
+ You can close this page. You will be logged in automatically once
91
+ you verify your email.
92
+ </template>
93
+ </UAlert>
94
+
95
+ <UAlert
96
+ icon="lucide:alert-triangle"
97
+ color="warning"
98
+ variant="outline"
99
+ >
100
+ <template #description>
101
+ If you don't see the email, please check your spam folder.
102
+ </template>
103
+ </UAlert>
104
+ </div>
105
+ </div>
106
+
107
+ <form v-else @submit.prevent="submitForm">
54
108
  <div class="flex flex-col gap-y-6">
55
109
  <h1 class="text-3xl font-bold">Create Account</h1>
56
110
 
57
- <UFormField label="Email">
111
+ <UFormField label="Email" required>
58
112
  <UInput
59
113
  v-model="form.email"
60
114
  type="email"
@@ -65,7 +119,7 @@ async function submitForm() {
65
119
  </UFormField>
66
120
 
67
121
  <div class="flex gap-x-4">
68
- <UFormField label="Username">
122
+ <UFormField label="Username" required>
69
123
  <UInput
70
124
  v-model="form.username"
71
125
  placeholder="e.g: johndoe"
@@ -75,7 +129,7 @@ async function submitForm() {
75
129
  />
76
130
  </UFormField>
77
131
 
78
- <UFormField label="Display Name">
132
+ <UFormField label="Display Name" required>
79
133
  <UInput
80
134
  v-model="form.display_name"
81
135
  placeholder="e.g: John Doe"
@@ -85,7 +139,7 @@ async function submitForm() {
85
139
  </UFormField>
86
140
  </div>
87
141
 
88
- <UFormField :error="!passwordMatch" label="Password">
142
+ <UFormField :error="!passwordMatch" label="Password" required>
89
143
  <UInput
90
144
  v-model="form.password"
91
145
  placeholder="••••"
@@ -95,7 +149,7 @@ async function submitForm() {
95
149
  />
96
150
  </UFormField>
97
151
 
98
- <UFormField :error="!passwordMatch" label="Confirm Password">
152
+ <UFormField :error="!passwordMatch" label="Confirm Password" required>
99
153
  <UInput
100
154
  v-model="form.confirm_password"
101
155
  placeholder="••••"