diff --git a/src/auth/components/signup.vue b/src/auth/components/signup.vue index b8df156..09bcaef 100644 --- a/src/auth/components/signup.vue +++ b/src/auth/components/signup.vue @@ -1,31 +1,25 @@ - - - - - Cancel - - - Modal - - - Confirm - - - - - - - - - + + + + + + Close + + + + + + + + diff --git a/src/auth/components/verify-code.vue b/src/auth/components/verify-code.vue new file mode 100644 index 0000000..2721253 --- /dev/null +++ b/src/auth/components/verify-code.vue @@ -0,0 +1,139 @@ + + + + + What's your email? + You'll use this email to login and access everything we have to offer. + + + + + + + + Sign up + + + + + + + Phone Number + + + + Google + + + + + Verify your email + We have sent a verification code to {{ form.email }}. Please enter the code below to verify your email address. + + + + + + + + Submit + + + + + + diff --git a/src/auth/index.ts b/src/auth/index.ts index 4d597ba..28565af 100644 --- a/src/auth/index.ts +++ b/src/auth/index.ts @@ -1,12 +1,19 @@ import { modalController } from "@ionic/vue"; +import { emailOTPClient } from "better-auth/client/plugins"; import { createAuthClient } from "better-auth/vue"; +import SignupContent from "./components/signup.vue"; export const authClient = createAuthClient({ baseURL: import.meta.env.VITE_BASE_API_URL, // The base URL of your auth server + plugins: [emailOTPClient()], }); -export function signupController() { - return modalController.create({ - component: () => import("./components/signup.vue"), +export async function modelControllerSignup(presentingElement?: HTMLElement) { + const modal = await modalController.create({ + component: SignupContent, + presentingElement, + canDismiss: async (data, role) => role !== "gesture", }); + + return modal; } diff --git a/src/auth/type.ts b/src/auth/type.ts new file mode 100644 index 0000000..f2076c1 --- /dev/null +++ b/src/auth/type.ts @@ -0,0 +1,6 @@ +export interface AuthUserSignup { + email: string; + password: string; + confirmPassword: string; + verificationCode: string; +} diff --git a/src/composables/useAuth.ts b/src/composables/useAuth.ts new file mode 100644 index 0000000..e23ed69 --- /dev/null +++ b/src/composables/useAuth.ts @@ -0,0 +1,15 @@ +import { authClient } from "@/auth"; + +export function useAuth() { + // Better Auth ζδΎη session + const session = authClient.useSession(); + + const user = computed(() => session.value.data?.user); + const isAuthenticated = computed(() => !!session.value.data); + + return { + user, + session, + isAuthenticated, + }; +} diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..7cd62fb --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,2 @@ +export * from "./ionic-helper"; +export * from "./pattern"; diff --git a/src/utils/ionic-helper.ts b/src/utils/ionic-helper.ts new file mode 100644 index 0000000..c30ee43 --- /dev/null +++ b/src/utils/ionic-helper.ts @@ -0,0 +1 @@ +export type PageInstance = InstanceType; diff --git a/src/utils/pattern.ts b/src/utils/pattern.ts new file mode 100644 index 0000000..8d09dc6 --- /dev/null +++ b/src/utils/pattern.ts @@ -0,0 +1 @@ +export const emailPattern = /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/;
You'll use this email to login and access everything we have to offer.
We have sent a verification code to {{ form.email }}. Please enter the code below to verify your email address.