The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Docs/UI library vue nuxt password auth (#39405)
Jakub Andrzejewski3485cd4965a3
diff --git a/apps/docs/package.json b/apps/docs/package.jsonindex 999b11fd216..5cabf323afa 100644--- a/apps/docs/package.json+++ b/apps/docs/package.json@@ -153,6 +153,7 @@"graphiql": "^4.0.2","openapi-types": "^12.1.3","postcss": "^8.5.3",+ "tailwindcss": "catalog:","shiki": "^3.2.1","shx": "^0.4.0","simple-git": "^3.24.0",diff --git a/apps/ui-library/config/docs.ts b/apps/ui-library/config/docs.tsindex da2017ab269..5e005ea9937 100644--- a/apps/ui-library/config/docs.ts+++ b/apps/ui-library/config/docs.ts@@ -61,7 +61,7 @@ export const componentPages: SidebarNavGroup = {},{title: 'Password-Based Auth',- supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react'],+ supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react', 'vue', 'nuxtjs'],href: '/docs/nextjs/password-based-auth',items: [],commandItemLabel: 'Password-Based Auth',diff --git a/apps/ui-library/content/docs/nuxtjs/password-based-auth.mdx b/apps/ui-library/content/docs/nuxtjs/password-based-auth.mdxnew file mode 100644index 00000000000..00b95975705--- /dev/null+++ b/apps/ui-library/content/docs/nuxtjs/password-based-auth.mdx@@ -0,0 +1,83 @@+---+title: Password-based Authentication+description: Password-based authentication block for Nuxt.js+---++<BlockPreview name="password-based-auth/auth/sign-up" />++## Installation++<BlockItem+ name="password-based-auth-nuxtjs"+ description="All needed components for the password based auth flow"+/>++## Folder structure++This block assumes that you have already installed a Supabase client for Nuxt from the previous step.++<RegistryBlock itemName="password-based-auth-nuxtjs" />++## Usage++Once you install the block in your Next.js project, you'll get all the necessary pages and components to set up a password-based authentication flow.++### Getting started++After installing the block, you'll have the following environment variables in your `.env.local` file:++```env+NUXT_PUBLIC_SUPABASE_URL=+NUXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY=+```++- If you're using supabase.com, you can find these values in the [Connect modal](https://supabase.com/dashboard/project/_?showConnect=true) under App Frameworks or in your project's [API settings](https://supabase.com/dashboard/project/_/settings/api).++- If you're using a local instance of Supabase, you can find these values by running `supabase start` or `supabase status` (if you already have it running).++### Adding email templates++1. Add an [email template for sign-up](https://supabase.com/dashboard/project/_/auth/templates) to the Supabase project. Your signup email template should contain at least the following HTML:++ ```html+ <h2>Confirm your signup</h2>++ <p>Follow this link to confirm your user:</p>+ <p>+ <a+ href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=email&next={{ .RedirectTo }}"+ >Confirm your email</a+ >+ </p>+ ```++ For detailed instructions on how to configure your email templates, including the use of variables like `{{ .SiteURL }}`,`{{ .TokenHash }}`, and `{{ .RedirectTo }}`, refer to our [Email Templates guide](https://supabase.com/docs/email-templates).++1. Add an [email template for reset password](https://supabase.com/dashboard/project/_/auth/templates) to the Supabase project. Your reset password email template should contain at least the following HTML:++ ```html+ <h2>Reset Password</h2>++ <p>Follow this link to reset the password for your user:</p>+ <p>+ <a+ href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=recovery&next={{ .RedirectTo }}"+ >Reset Password</a+ >+ </p>+ ```++### Setting up routes and redirect URLs++1. Set the site URL in the [URL Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) settings in the Supabase Dashboard.+1. Set up the Next.js route that users will visit to reset or update their password. Go to the [URL Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) settings and add the `forgot-password` route to the list of Redirect URLs. It should look something like: `http://example.com/auth/forgot-password`.++1. Update the redirect paths in `login-form.vue` and `update-password-form.vue` components to point to the logged-in routes in your app. Our examples use `/protected`, but you can set this to whatever fits your app.++## Further reading++- [Password-based authentication (PKCE flow)](https://supabase.com/docs/guides/auth/passwords?queryGroups=flow&flow=pkce)+- [Authentication error codes](https://supabase.com/docs/guides/auth/debugging/error-codes)+- [Email templates](https://supabase.com/docs/guides/auth/auth-email-templates)+- [Email templates for local development](https://supabase.com/docs/guides/local-development/customizing-email-templates)+- [Custom SMTP](https://supabase.com/docs/guides/auth/auth-smtp)diff --git a/apps/ui-library/content/docs/vue/password-based-auth.mdx b/apps/ui-library/content/docs/vue/password-based-auth.mdxnew file mode 100644index 00000000000..fc9094e8d24--- /dev/null+++ b/apps/ui-library/content/docs/vue/password-based-auth.mdx@@ -0,0 +1,75 @@+---+title: Password-based Authentication+description: Password-based authentication block for Vue Single Page Applications+---++<BlockPreview name="password-based-auth/auth/sign-up" />++## Installation++<BlockItem+ name="password-based-auth-vue"+ description="All needed components for the password based auth flow"+/>++## Folder structure++This block assumes that you have already installed a Supabase client for Vue from the previous step.++<RegistryBlock itemName="password-based-auth-vue" />++## Usage++Once you install the block in your Vue project, you'll get all the necessary components to set up a password-based authentication flow.++### Getting started++After installing the block, you'll have the following environment variables in your `.env.local` file:++```env+VITE_SUPABASE_URL=+VITE_SUPABASE_PUBLISHABLE_OR_ANON_KEY=+```++- If you're using supabase.com, you can find these values in the [Connect modal](https://supabase.com/dashboard/project/_?showConnect=true&tab=frameworks&framework=vuejs&using=supabasejs) under App Frameworks or in your project's [API keys](https://supabase.com/dashboard/project/_/settings/api-keys).++- If you're using a local instance of Supabase, you can find these values by running `supabase start` or `supabase status` (if you already have it running).++### Setting up routes and redirect URLs++1. Set the site URL in the [URL Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) settings in the Supabase Dashboard.+1. Set up the route users will visit to reset or update their password. Go to the [URL Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) settings and add the `forgot-password` route to the list of Redirect URLs. It should look something like: `http://example.com/auth/forgot-password`.+1. Update the redirect paths in `login.vue` and `update-password.vue` components to point to the logged-in routes in your app. Our examples use `/protected`, but you can set this to whatever fits your app.++1. Add the following code in the authenticated route to redirect to login if the user is unauthenticated.++```vue+<script setup lang="ts">+import { onMounted } from 'vue'+import { createClient } from '@/lib/supabase/client'++onMounted(async () => {+ const client = createClient()++ const { error } = await client.auth.getUser()++ if (error) {+ location.href = '/login'+ }+})+</script>++<template>+ <div>Authenticated page</div>+</template>+```++Additionally, you could utilize the Navigation Guards from `vue-router` explained [here](https://router.vuejs.org/guide/advanced/navigation-guards#Global-Before-Guards).++## Further reading++- [Password-based authentication (implicit flow)](https://supabase.com/docs/guides/auth/passwords?queryGroups=flow&flow=implicit)+- [Authentication error codes](https://supabase.com/docs/guides/auth/debugging/error-codes)+- [Email templates](https://supabase.com/docs/guides/auth/auth-email-templates)+- [Email templates for local development](https://supabase.com/docs/guides/local-development/customizing-email-templates)+- [Custom SMTP](https://supabase.com/docs/guides/auth/auth-smtp)diff --git a/apps/ui-library/public/llms.txt b/apps/ui-library/public/llms.txtindex bea8b27be06..aa18fe91ff8 100644--- a/apps/ui-library/public/llms.txt+++ b/apps/ui-library/public/llms.txt@@ -1,5 +1,5 @@# Supabase UI Library-Last updated: 2025-10-15T07:54:48.550Z+Last updated: 2025-11-06T16:46:13.786Z## OverviewLibrary of components for your project. The components integrate with Supabase and are shadcn compatible.@@ -33,6 +33,8 @@ Library of components for your project. The components integrate with Supabase a- Social authentication block for Next.js- [Supabase Client Libraries](https://supabase.com/ui/docs/nuxtjs/client)- Supabase client for Nuxt.js+- [Password-based Authentication](https://supabase.com/ui/docs/nuxtjs/password-based-auth)+ - Password-based authentication block for Nuxt.js- [Platform Kit](https://supabase.com/ui/docs/platform/platform-kit)- The easiest way to build platforms on top of Supabase- [Supabase Client Libraries](https://supabase.com/ui/docs/react-router/client)@@ -85,3 +87,5 @@ Library of components for your project. The components integrate with Supabase a- Social authentication block for Tanstack Start- [Supabase Client Libraries](https://supabase.com/ui/docs/vue/client)- Supabase client for Vue Single Page Applications+- [Password-based Authentication](https://supabase.com/ui/docs/vue/password-based-auth)+ - Password-based authentication block for Vue Single Page Applicationsdiff --git a/apps/ui-library/public/r/infinite-query-hook.json b/apps/ui-library/public/r/infinite-query-hook.jsonindex d795b7b6e1a..5ed44d9e635 100644--- a/apps/ui-library/public/r/infinite-query-hook.json+++ b/apps/ui-library/public/r/infinite-query-hook.json@@ -12,7 +12,7 @@"files": [{"path": "registry/default/blocks/infinite-query-hook/hooks/use-infinite-query.ts",- "content": "'use client'\n\nimport { createClient } from '@/registry/default/fixtures/lib/supabase/client'\nimport { PostgrestQueryBuilder } from '@supabase/postgrest-js'\nimport { type SupabaseClient } from '@supabase/supabase-js'\nimport { useEffect, useRef, useSyncExternalStore } from 'react'\n\nconst supabase = createClient()\n\n// The following types are used to make the hook type-safe. It extracts the database type from the supabase client.\ntype SupabaseClientType = typeof supabase\n\n// Utility type to check if the type is any\ntype IfAny<T, Y, N> = 0 extends 1 & T ? Y : N\n\n// Extracts the database type from the supabase client. If the supabase client doesn't have a type, it will fallback properly.\ntype Database =\n SupabaseClientType extends SupabaseClient<infer U>\n ? IfAny<\n U,\n {\n public: {\n Tables: Record<string, any>\n Views: Record<string, any>\n Functions: Record<string, any>\n }\n },\n U\n >\n : {\n public: {\n Tables: Record<string, any>\n Views: Record<string, any>\n Functions: Record<string, any>\n }\n }\n\n// Change this to the database schema you want to use\ntype DatabaseSchema = Database['public']\n\n// Extracts the table names from the database type\ntype SupabaseTableName = keyof DatabaseSchema['Tables']\n\n// Extracts the table definition from the database type\ntype SupabaseTableData<T extends SupabaseTableName> = DatabaseSchema['Tables'][T]['Row']\n\ntype SupabaseSelectBuilder<T extends SupabaseTableName> = ReturnType<\n PostgrestQueryBuilder<DatabaseSchema, DatabaseSchema['Tables'][T], T>['select']\n>\n\n// A function that modifies the query. Can be used to sort, filter, etc. If .range is used, it will be overwritten.\ntype SupabaseQueryHandler<T extends SupabaseTableName> = (\n query: SupabaseSelectBuilder<T>\n) => SupabaseSelectBuilder<T>\n\ninterface UseInfiniteQueryProps<T extends SupabaseTableName, Query extends string = '*'> {\n // The table name to query\n tableName: T\n // The columns to select, defaults to `*`\n columns?: string\n // The number of items to fetch per page, defaults to `20`\n pageSize?: number\n // A function that modifies the query. Can be used to sort, filter, etc. If .range is used, it will be overwritten.\n trailingQuery?: SupabaseQueryHandler<T>\n}\n\ninterface StoreState<TData> {\n data: TData[]\n count: number\n isSuccess: boolean\n isLoading: boolean\n isFetching: boolean\n error: Error | null\n hasInitialFetch: boolean\n}\n\ntype Listener = () => void\n\nfunction createStore<TData extends SupabaseTableData<T>, T extends SupabaseTableName>(\n props: UseInfiniteQueryProps<T>\n) {\n const { tableName, columns = '*', pageSize = 20, trailingQuery } = props\n\n let state: StoreState<TData> = {\n data: [],\n count: 0,\n isSuccess: false,\n isLoading: false,\n isFetching: false,\n error: null,\n hasInitialFetch: false,\n }\n\n const listeners = new Set<Listener>()\n\n const notify = () => {\n listeners.forEach((listener) => listener())\n }\n\n const setState = (newState: Partial<StoreState<TData>>) => {\n state = { ...state, ...newState }\n notify()\n }\n\n const fetchPage = async (skip: number) => {\n if (state.hasInitialFetch && (state.isFetching || state.count <= state.data.length)) return\n\n setState({ isFetching: true })\n\n let query = supabase\n .from(tableName)\n .select(columns, { count: 'exact' }) as unknown as SupabaseSelectBuilder<T>\n\n if (trailingQuery) {\n query = trailingQuery(query)\n }\n const { data: newData, count, error } = await query.range(skip, skip + pageSize - 1)\n\n if (error) {\n console.error('An unexpected error occurred:', error)\n setState({ error })\n } else {\n setState({\n data: [...state.data, ...(newData as TData[])],\n count: count || 0,\n isSuccess: true,\n error: null,\n })\n }\n setState({ isFetching: false })\n }\n\n const fetchNextPage = async () => {\n if (state.isFetching) return\n await fetchPage(state.data.length)\n }\n\n const initialize = async () => {\n setState({ isLoading: true, isSuccess: false, data: [] })\n await fetchNextPage()\n setState({ isLoading: false, hasInitialFetch: true })\n }\n\n return {\n getState: () => state,\n subscribe: (listener: Listener) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n fetchNextPage,\n initialize,\n }\n}\n\n// Empty initial state to avoid hydration errors.\nconst initialState: any = {\n data: [],\n count: 0,\n isSuccess: false,\n isLoading: false,\n isFetching: false,\n error: null,\n hasInitialFetch: false,\n}\n\nfunction useInfiniteQuery<\n TData extends SupabaseTableData<T>,\n T extends SupabaseTableName = SupabaseTableName,\n>(props: UseInfiniteQueryProps<T>) {\n const storeRef = useRef(createStore<TData, T>(props))\n\n const state = useSyncExternalStore(\n storeRef.current.subscribe,\n () => storeRef.current.getState(),\n () => initialState as StoreState<TData>\n )\n\n useEffect(() => {\n // Recreate store if props change\n if (\n storeRef.current.getState().hasInitialFetch &&\n (props.tableName !== props.tableName ||\n props.columns !== props.columns ||\n props.pageSize !== props.pageSize)\n ) {\n storeRef.current = createStore<TData, T>(props)\n }\n\n if (!state.hasInitialFetch && typeof window !== 'undefined') {\n storeRef.current.initialize()\n }\n }, [props.tableName, props.columns, props.pageSize, state.hasInitialFetch])\n\n return {\n data: state.data,\n count: state.count,\n isSuccess: state.isSuccess,\n isLoading: state.isLoading,\n isFetching: state.isFetching,\n error: state.error,\n hasMore: state.count > state.data.length,\n fetchNextPage: storeRef.current.fetchNextPage,\n }\n}\n\nexport {\n useInfiniteQuery,\n type SupabaseQueryHandler,\n type SupabaseTableData,\n type SupabaseTableName,\n type UseInfiniteQueryProps,\n}\n",+ "content": "'use client'\n\nimport { createClient } from '@/registry/default/fixtures/lib/supabase/client'\nimport { PostgrestQueryBuilder, type PostgrestClientOptions } from '@supabase/postgrest-js'\nimport { type SupabaseClient } from '@supabase/supabase-js'\nimport { useEffect, useRef, useSyncExternalStore } from 'react'\n\nconst supabase = createClient()\n\n// The following types are used to make the hook type-safe. It extracts the database type from the supabase client.\ntype SupabaseClientType = typeof supabase\n\n// Utility type to check if the type is any\ntype IfAny<T, Y, N> = 0 extends 1 & T ? Y : N\n\n// Extracts the database type from the supabase client. If the supabase client doesn't have a type, it will fallback properly.\ntype Database =\n SupabaseClientType extends SupabaseClient<infer U>\n ? IfAny<\n U,\n {\n public: {\n Tables: Record<string, any>\n Views: Record<string, any>\n Functions: Record<string, any>\n }\n },\n U\n >\n : {\n public: {\n Tables: Record<string, any>\n Views: Record<string, any>\n Functions: Record<string, any>\n }\n }\n\n// Change this to the database schema you want to use\ntype DatabaseSchema = Database['public']\n\n// Extracts the table names from the database type\ntype SupabaseTableName = keyof DatabaseSchema['Tables']\n\n// Extracts the table definition from the database type\ntype SupabaseTableData<T extends SupabaseTableName> = DatabaseSchema['Tables'][T]['Row']\n\n// Default client options for PostgrestQueryBuilder\ntype DefaultClientOptions = PostgrestClientOptions\n\ntype SupabaseSelectBuilder<T extends SupabaseTableName> = ReturnType<\n PostgrestQueryBuilder<\n DefaultClientOptions,\n DatabaseSchema,\n DatabaseSchema['Tables'][T],\n T\n >['select']\n>\n\n// A function that modifies the query. Can be used to sort, filter, etc. If .range is used, it will be overwritten.\ntype SupabaseQueryHandler<T extends SupabaseTableName> = (\n query: SupabaseSelectBuilder<T>\n) => SupabaseSelectBuilder<T>\n\ninterface UseInfiniteQueryProps<T extends SupabaseTableName, Query extends string = '*'> {\n // The table name to query\n tableName: T\n // The columns to select, defaults to `*`\n columns?: string\n // The number of items to fetch per page, defaults to `20`\n pageSize?: number\n // A function that modifies the query. Can be used to sort, filter, etc. If .range is used, it will be overwritten.\n trailingQuery?: SupabaseQueryHandler<T>\n}\n\ninterface StoreState<TData> {\n data: TData[]\n count: number\n isSuccess: boolean\n isLoading: boolean\n isFetching: boolean\n error: Error | null\n hasInitialFetch: boolean\n}\n\ntype Listener = () => void\n\nfunction createStore<TData extends SupabaseTableData<T>, T extends SupabaseTableName>(\n props: UseInfiniteQueryProps<T>\n) {\n const { tableName, columns = '*', pageSize = 20, trailingQuery } = props\n\n let state: StoreState<TData> = {\n data: [],\n count: 0,\n isSuccess: false,\n isLoading: false,\n isFetching: false,\n error: null,\n hasInitialFetch: false,\n }\n\n const listeners = new Set<Listener>()\n\n const notify = () => {\n listeners.forEach((listener) => listener())\n }\n\n const setState = (newState: Partial<StoreState<TData>>) => {\n state = { ...state, ...newState }\n notify()\n }\n\n const fetchPage = async (skip: number) => {\n if (state.hasInitialFetch && (state.isFetching || state.count <= state.data.length)) return\n\n setState({ isFetching: true })\n\n let query = supabase\n .from(tableName)\n .select(columns, { count: 'exact' }) as unknown as SupabaseSelectBuilder<T>\n\n if (trailingQuery) {\n query = trailingQuery(query)\n }\n const { data: newData, count, error } = await query.range(skip, skip + pageSize - 1)\n\n if (error) {\n console.error('An unexpected error occurred:', error)\n setState({ error })\n } else {\n setState({\n data: [...state.data, ...(newData as TData[])],\n count: count || 0,\n isSuccess: true,\n error: null,\n })\n }\n setState({ isFetching: false })\n }\n\n const fetchNextPage = async () => {\n if (state.isFetching) return\n await fetchPage(state.data.length)\n }\n\n const initialize = async () => {\n setState({ isLoading: true, isSuccess: false, data: [] })\n await fetchNextPage()\n setState({ isLoading: false, hasInitialFetch: true })\n }\n\n return {\n getState: () => state,\n subscribe: (listener: Listener) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n fetchNextPage,\n initialize,\n }\n}\n\n// Empty initial state to avoid hydration errors.\nconst initialState: any = {\n data: [],\n count: 0,\n isSuccess: false,\n isLoading: false,\n isFetching: false,\n error: null,\n hasInitialFetch: false,\n}\n\nfunction useInfiniteQuery<\n TData extends SupabaseTableData<T>,\n T extends SupabaseTableName = SupabaseTableName,\n>(props: UseInfiniteQueryProps<T>) {\n const storeRef = useRef(createStore<TData, T>(props))\n\n const state = useSyncExternalStore(\n storeRef.current.subscribe,\n () => storeRef.current.getState(),\n () => initialState as StoreState<TData>\n )\n\n useEffect(() => {\n // Recreate store if props change\n if (\n storeRef.current.getState().hasInitialFetch &&\n (props.tableName !== props.tableName ||\n props.columns !== props.columns ||\n props.pageSize !== props.pageSize)\n ) {\n storeRef.current = createStore<TData, T>(props)\n }\n\n if (!state.hasInitialFetch && typeof window !== 'undefined') {\n storeRef.current.initialize()\n }\n }, [props.tableName, props.columns, props.pageSize, state.hasInitialFetch])\n\n return {\n data: state.data,\n count: state.count,\n isSuccess: state.isSuccess,\n isLoading: state.isLoading,\n isFetching: state.isFetching,\n error: state.error,\n hasMore: state.count > state.data.length,\n fetchNextPage: storeRef.current.fetchNextPage,\n }\n}\n\nexport {\n useInfiniteQuery,\n type SupabaseQueryHandler,\n type SupabaseTableData,\n type SupabaseTableName,\n type UseInfiniteQueryProps,\n}\n","type": "registry:hook"}]diff --git a/apps/ui-library/public/r/password-based-auth-nuxtjs.json b/apps/ui-library/public/r/password-based-auth-nuxtjs.jsonnew file mode 100644index 00000000000..b0ea37e7631--- /dev/null+++ b/apps/ui-library/public/r/password-based-auth-nuxtjs.json@@ -0,0 +1,91 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "password-based-auth-nuxtjs",+ "type": "registry:block",+ "title": "Password Based Auth flow for Nuxt.js and Supabase",+ "description": "Password Based Auth flow for Nuxt.js and Supabase",+ "dependencies": [+ "@supabase/ssr@latest",+ "@supabase/supabase-js@latest"+ ],+ "registryDependencies": [+ "button",+ "card",+ "input",+ "label"+ ],+ "files": [+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/login-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst email = ref(\"\")\nconst error = ref<string | null>(null)\nconst success = ref(false)\nconst isLoading = ref(false)\n\nconst handleForgotPassword = async (e: Event) => {\n e.preventDefault()\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {\n redirectTo: \"http://localhost:3000/update-password\",\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset email.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit=\"handleForgotPassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Sending...\" : \"Send reset email\" }}\n </Button>\n </div>\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/components/login-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/sign-up-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst email = ref(\"\")\nconst password = ref(\"\")\nconst repeatPassword = ref(\"\")\nconst error = ref<string | null>(null)\nconst isLoading = ref(false)\nconst success = ref(false)\n\nconst handleSignUp = async () => {\n const supabase = createClient()\n error.value = null\n\n if (password.value !== repeatPassword.value) {\n error.value = \"Passwords do not match\"\n return\n }\n\n isLoading.value = true\n try {\n const { error: supabaseError } = await supabase.auth.signUp({\n email: email.value,\n password: password.value,\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Thank you for signing up!</CardTitle>\n <CardDescription>Check your email to confirm</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n You've successfully signed up. Please check your email to confirm your account before\n signing in.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Sign up</CardTitle>\n <CardDescription>Create a new account</CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit.prevent=\"handleSignUp\">\n <div class=\"flex flex-col gap-6\">\n <!-- Email -->\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n\n <!-- Password -->\n <div class=\"grid gap-2\">\n <div class=\"flex items-center\">\n <Label for=\"password\">Password</Label>\n </div>\n <Input\n id=\"password\"\n type=\"password\"\n required\n v-model=\"password\"\n />\n </div>\n\n <!-- Repeat Password -->\n <div class=\"grid gap-2\">\n <div class=\"flex items-center\">\n <Label for=\"repeat-password\">Repeat Password</Label>\n </div>\n <Input\n id=\"repeat-password\"\n type=\"password\"\n required\n v-model=\"repeatPassword\"\n />\n </div>\n\n <!-- Error -->\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n\n <!-- Submit -->\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Creating an account...\" : \"Sign up\" }}\n </Button>\n </div>\n\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/components/sign-up-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/forgot-password-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\n\nconst email = ref(\"\")\nconst error = ref<string | null>(null)\nconst success = ref(false)\nconst isLoading = ref(false)\n\nconst handleForgotPassword = async (e: Event) => {\n e.preventDefault()\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {\n redirectTo: \"http://localhost:3000/update-password\",\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset email.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit=\"handleForgotPassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Sending...\" : \"Send reset email\" }}\n </Button>\n </div>\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/components/forgot-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/update-password-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst password = ref(\"\")\nconst error = ref<string | null>(null)\nconst isLoading = ref(false)\n\nconst handleUpdatePassword = async () => {\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.updateUser({\n password: password.value,\n })\n if (supabaseError) throw supabaseError\n // Redirect user after successful password update\n location.href = \"/protected\"\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>Please enter your new password below.</CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit.prevent=\"handleUpdatePassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"password\">New password</Label>\n <Input\n id=\"password\"\n type=\"password\"\n placeholder=\"New password\"\n required\n v-model=\"password\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Saving...\" : \"Save new password\" }}\n </Button>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/components/update-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/login.vue",+ "content": "<script setup lang=\"ts\">\nimport LoginForm from \"@/components/login-form.vue\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <LoginForm />\n </div>\n </div>\n</template>",+ "type": "registry:file",+ "target": "app/pages/auth/login.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up.vue",+ "content": "<script setup lang=\"ts\">\nimport SignUpForm from \"@/components/sign-up-form.vue\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <SignUpForm />\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/forgot-password.vue",+ "content": "<script setup lang=\"ts\">\nimport ForgotPasswordForm from \"@/components/forgot-password-form.vue\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <ForgotPasswordForm />\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/auth/forgot-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/update-password.vue",+ "content": "<script setup lang=\"ts\">\nimport UpdatePasswordForm from \"@/components/update-password-form.vue\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <UpdatePasswordForm />\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/auth/update-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/error.vue",+ "content": "<script setup lang=\"ts\">\nimport { useRoute } from \"vue-router\"\nimport { computed } from \"vue\"\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\"\n\nconst route = useRoute()\nconst errorMessage = computed(() => route.query.error as string || null)\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <div class=\"flex flex-col gap-6\">\n <Card>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Sorry, something went wrong.</CardTitle>\n </CardHeader>\n <CardContent>\n <p v-if=\"errorMessage\" class=\"text-sm text-muted-foreground\">\n Code error: {{ errorMessage }}\n </p>\n <p v-else class=\"text-sm text-muted-foreground\">\n An unspecified error occurred.\n </p>\n </CardContent>\n </Card>\n </div>\n </div>\n </div>\n</template>",+ "type": "registry:file",+ "target": "app/pages/auth/error.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up-success.vue",+ "content": "<script setup lang=\"ts\">\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <div class=\"flex flex-col gap-6\">\n <Card>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Thank you for signing up!</CardTitle>\n <CardDescription>Check your email to confirm</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n You’ve successfully signed up. Please check your email to confirm your account\n before signing in.\n </p>\n </CardContent>\n </Card>\n </div>\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up-success.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/protected/index.vue",+ "content": "<script setup lang=\"ts\">\nimport { onMounted, ref } from \"vue\"\nimport { useRouter } from \"vue-router\"\nimport { createClient } from \"@/lib/supabase/client\"\n\nconst router = useRouter()\nconst supabase = createClient()\nconst email = ref<string | null>(null)\nconst loading = ref(true)\n\nonMounted(async () => {\n const { data, error } = await supabase.auth.getUser()\n\n if (error || !data?.user) {\n router.replace(\"/auth/login\")\n return\n }\n\n email.value = data.user.email\n loading.value = false\n})\n\nconst handleLogout = async () => {\n await supabase.auth.signOut()\n router.replace(\"/auth/login\")\n}\n</script>\n\n<template>\n <div class=\"flex h-screen w-full items-center justify-center\">\n <div v-if=\"loading\" class=\"text-muted-foreground\">Checking authentication...</div>\n\n <div v-else class=\"flex items-center gap-2\">\n <p>\n Hello <span class=\"font-semibold\">{{ email }}</span>\n </p>\n <button\n class=\"rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium hover:bg-primary/90\"\n @click=\"handleLogout\"\n >\n Logout\n </button>\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/protected/index.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/server/routes/auth/confirm.get.ts",+ "content": "import { getQuery, defineEventHandler, sendRedirect } from 'h3'\nimport type { EmailOtpType } from '@supabase/supabase-js'\nimport { createSupabaseServerClient } from '@/registry/default/clients/nuxtjs/server/supabase/client'\n\nexport default defineEventHandler(async (event) => {\n const query = getQuery(event)\n const token_hash = query.token_hash as string | null\n const type = query.type as EmailOtpType | null\n const _next = query.next as string | undefined\n const next = _next?.startsWith('/') ? _next : '/'\n\n if (token_hash && type) {\n const supabase = createSupabaseServerClient(event)\n\n const { error } = await supabase.auth.verifyOtp({\n type,\n token_hash,\n })\n\n if (!error) {\n return sendRedirect(event, next)\n } else {\n return sendRedirect(event, `/auth/error?error=${encodeURIComponent(error.message)}`)\n }\n }\n\n return sendRedirect(event, `/auth/error?error=${encodeURIComponent('No token hash or type')}`)\n})\n",+ "type": "registry:file",+ "target": "server/routes/auth/confirm.get.ts"+ }+ ]+}\ No newline at end of filediff --git a/apps/ui-library/public/r/password-based-auth-vue.json b/apps/ui-library/public/r/password-based-auth-vue.jsonnew file mode 100644index 00000000000..4b5b1d4b10e--- /dev/null+++ b/apps/ui-library/public/r/password-based-auth-vue.json@@ -0,0 +1,38 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "password-based-auth-vue",+ "type": "registry:block",+ "title": "Password Based Auth flow for Vue and Supabase",+ "description": "Password Based Auth flow for Vue and Supabase",+ "dependencies": [+ "@supabase/supabase-js@latest"+ ],+ "registryDependencies": [+ "button",+ "card",+ "input",+ "label"+ ],+ "files": [+ {+ "path": "registry/default/password-based-auth/vue/components/login-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst email = ref(\"\")\nconst error = ref<string | null>(null)\nconst success = ref(false)\nconst isLoading = ref(false)\n\nconst handleForgotPassword = async (e: Event) => {\n e.preventDefault()\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {\n redirectTo: \"http://localhost:3000/update-password\",\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset email.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit=\"handleForgotPassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Sending...\" : \"Send reset email\" }}\n </Button>\n </div>\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:component"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/sign-up-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst email = ref(\"\")\nconst password = ref(\"\")\nconst repeatPassword = ref(\"\")\nconst error = ref<string | null>(null)\nconst isLoading = ref(false)\nconst success = ref(false)\n\nconst handleSignUp = async () => {\n const supabase = createClient()\n error.value = null\n\n if (password.value !== repeatPassword.value) {\n error.value = \"Passwords do not match\"\n return\n }\n\n isLoading.value = true\n try {\n const { error: supabaseError } = await supabase.auth.signUp({\n email: email.value,\n password: password.value,\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Thank you for signing up!</CardTitle>\n <CardDescription>Check your email to confirm</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n You've successfully signed up. Please check your email to confirm your account before\n signing in.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Sign up</CardTitle>\n <CardDescription>Create a new account</CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit.prevent=\"handleSignUp\">\n <div class=\"flex flex-col gap-6\">\n <!-- Email -->\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n\n <!-- Password -->\n <div class=\"grid gap-2\">\n <div class=\"flex items-center\">\n <Label for=\"password\">Password</Label>\n </div>\n <Input\n id=\"password\"\n type=\"password\"\n required\n v-model=\"password\"\n />\n </div>\n\n <!-- Repeat Password -->\n <div class=\"grid gap-2\">\n <div class=\"flex items-center\">\n <Label for=\"repeat-password\">Repeat Password</Label>\n </div>\n <Input\n id=\"repeat-password\"\n type=\"password\"\n required\n v-model=\"repeatPassword\"\n />\n </div>\n\n <!-- Error -->\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n\n <!-- Submit -->\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Creating an account...\" : \"Sign up\" }}\n </Button>\n </div>\n\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:component"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/forgot-password-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\n\nconst email = ref(\"\")\nconst error = ref<string | null>(null)\nconst success = ref(false)\nconst isLoading = ref(false)\n\nconst handleForgotPassword = async (e: Event) => {\n e.preventDefault()\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {\n redirectTo: \"http://localhost:3000/update-password\",\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset email.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit=\"handleForgotPassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Sending...\" : \"Send reset email\" }}\n </Button>\n </div>\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:component"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/update-password-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst password = ref(\"\")\nconst error = ref<string | null>(null)\nconst isLoading = ref(false)\n\nconst handleUpdatePassword = async () => {\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.updateUser({\n password: password.value,\n })\n if (supabaseError) throw supabaseError\n // Redirect user after successful password update\n location.href = \"/protected\"\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>Please enter your new password below.</CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit.prevent=\"handleUpdatePassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"password\">New password</Label>\n <Input\n id=\"password\"\n type=\"password\"\n placeholder=\"New password\"\n required\n v-model=\"password\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Saving...\" : \"Save new password\" }}\n </Button>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:component"+ }+ ]+}\ No newline at end of filediff --git a/apps/ui-library/public/r/registry.json b/apps/ui-library/public/r/registry.jsonindex f541beefd3d..ddef884a812 100644--- a/apps/ui-library/public/r/registry.json+++ b/apps/ui-library/public/r/registry.json@@ -1761,6 +1761,117 @@}]},+ {+ "name": "password-based-auth-nuxtjs",+ "type": "registry:block",+ "title": "Password Based Auth flow for Nuxt.js and Supabase",+ "description": "Password Based Auth flow for Nuxt.js and Supabase",+ "registryDependencies": [+ "button",+ "card",+ "input",+ "label"+ ],+ "dependencies": [+ "@supabase/ssr@latest",+ "@supabase/supabase-js@latest"+ ],+ "files": [+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/login-form.vue",+ "type": "registry:file",+ "target": "app/components/login-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/sign-up-form.vue",+ "type": "registry:file",+ "target": "app/components/sign-up-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/forgot-password-form.vue",+ "type": "registry:file",+ "target": "app/components/forgot-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/update-password-form.vue",+ "type": "registry:file",+ "target": "app/components/update-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/login.vue",+ "type": "registry:file",+ "target": "app/pages/auth/login.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up.vue",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/forgot-password.vue",+ "type": "registry:file",+ "target": "app/pages/auth/forgot-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/update-password.vue",+ "type": "registry:file",+ "target": "app/pages/auth/update-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/error.vue",+ "type": "registry:file",+ "target": "app/pages/auth/error.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up-success.vue",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up-success.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/protected/index.vue",+ "type": "registry:file",+ "target": "app/pages/protected/index.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/server/routes/auth/confirm.get.ts",+ "type": "registry:file",+ "target": "server/routes/auth/confirm.get.ts"+ }+ ]+ },+ {+ "name": "password-based-auth-vue",+ "type": "registry:block",+ "title": "Password Based Auth flow for Vue and Supabase",+ "description": "Password Based Auth flow for Vue and Supabase",+ "registryDependencies": [+ "button",+ "card",+ "input",+ "label"+ ],+ "files": [+ {+ "path": "registry/default/password-based-auth/vue/components/login-form.vue",+ "type": "registry:component"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/sign-up-form.vue",+ "type": "registry:component"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/forgot-password-form.vue",+ "type": "registry:component"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/update-password-form.vue",+ "type": "registry:component"+ }+ ],+ "dependencies": [+ "@supabase/supabase-js@latest"+ ]+ },{"$schema": "https://ui.shadcn.com/schema/registry-item.json","name": "ai-editor-rules",diff --git a/blocks/vue/components.json b/blocks/vue/components.jsonindex 80d94f1fc9c..43a78ba6041 100644--- a/blocks/vue/components.json+++ b/blocks/vue/components.json@@ -14,8 +14,7 @@"components": "@/registry/default/components","utils": "@/lib/utils","ui": "@/registry/default/components/ui",- "lib": "@/lib",- "hooks": "@/hooks"+ "lib": "@/lib"},"iconLibrary": "lucide"}diff --git a/blocks/vue/index.ts b/blocks/vue/index.tsindex 85592bf74e8..f7764d229ff 100644--- a/blocks/vue/index.ts+++ b/blocks/vue/index.ts@@ -2,7 +2,7 @@ import { blocks as originBlocks } from './registry/index'const blocks = originBlocks.map((item) => {const newItem = { ...item }- newItem.files = newItem.files?.map((file) => {+ newItem.files = newItem.files?.map((file: any) => {if (file.path.startsWith('registry/')) {return { ...file, path: `node_modules/@supabase/vue-blocks/${file.path}` }}diff --git a/blocks/vue/package.json b/blocks/vue/package.jsonindex d7f3213264d..ba4c5e83bac 100644--- a/blocks/vue/package.json+++ b/blocks/vue/package.json@@ -12,6 +12,11 @@"dependencies": {"h3": "^1.15.4","nuxt": "^4.0.3",+ "class-variance-authority": "^0.7.1",+ "tailwind-merge": "^3.3.1",+ "clsx": "^2.1.1",+ "vue": "^3.5.21",+ "vue-router": "^4.5.1","@supabase/ssr": "^0.7.0","@supabase/supabase-js": "catalog:"},diff --git a/blocks/vue/public/r/password-based-auth-nuxtjs.json b/blocks/vue/public/r/password-based-auth-nuxtjs.jsonnew file mode 100644index 00000000000..ee53a2e435b--- /dev/null+++ b/blocks/vue/public/r/password-based-auth-nuxtjs.json@@ -0,0 +1,96 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "password-based-auth-nuxtjs",+ "type": "registry:lib",+ "title": "Password Based Auth flow for Nuxt.js and Supabase",+ "description": "",+ "dependencies": [+ "@supabase/ssr@latest",+ "@supabase/supabase-js@latest"+ ],+ "registryDependencies": [+ "button",+ "card",+ "input",+ "label"+ ],+ "files": [+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/login-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst email = ref(\"\")\nconst error = ref<string | null>(null)\nconst success = ref(false)\nconst isLoading = ref(false)\n\nconst handleForgotPassword = async (e: Event) => {\n e.preventDefault()\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {\n redirectTo: \"http://localhost:3000/update-password\",\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset email.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit=\"handleForgotPassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Sending...\" : \"Send reset email\" }}\n </Button>\n </div>\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/components/login-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/sign-up-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst email = ref(\"\")\nconst password = ref(\"\")\nconst repeatPassword = ref(\"\")\nconst error = ref<string | null>(null)\nconst isLoading = ref(false)\nconst success = ref(false)\n\nconst handleSignUp = async () => {\n const supabase = createClient()\n error.value = null\n\n if (password.value !== repeatPassword.value) {\n error.value = \"Passwords do not match\"\n return\n }\n\n isLoading.value = true\n try {\n const { error: supabaseError } = await supabase.auth.signUp({\n email: email.value,\n password: password.value,\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Thank you for signing up!</CardTitle>\n <CardDescription>Check your email to confirm</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n You've successfully signed up. Please check your email to confirm your account before\n signing in.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Sign up</CardTitle>\n <CardDescription>Create a new account</CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit.prevent=\"handleSignUp\">\n <div class=\"flex flex-col gap-6\">\n <!-- Email -->\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n\n <!-- Password -->\n <div class=\"grid gap-2\">\n <div class=\"flex items-center\">\n <Label for=\"password\">Password</Label>\n </div>\n <Input\n id=\"password\"\n type=\"password\"\n required\n v-model=\"password\"\n />\n </div>\n\n <!-- Repeat Password -->\n <div class=\"grid gap-2\">\n <div class=\"flex items-center\">\n <Label for=\"repeat-password\">Repeat Password</Label>\n </div>\n <Input\n id=\"repeat-password\"\n type=\"password\"\n required\n v-model=\"repeatPassword\"\n />\n </div>\n\n <!-- Error -->\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n\n <!-- Submit -->\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Creating an account...\" : \"Sign up\" }}\n </Button>\n </div>\n\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/components/sign-up-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/forgot-password-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\n\nconst email = ref(\"\")\nconst error = ref<string | null>(null)\nconst success = ref(false)\nconst isLoading = ref(false)\n\nconst handleForgotPassword = async (e: Event) => {\n e.preventDefault()\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {\n redirectTo: \"http://localhost:3000/update-password\",\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset email.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit=\"handleForgotPassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Sending...\" : \"Send reset email\" }}\n </Button>\n </div>\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/components/forgot-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/update-password-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst password = ref(\"\")\nconst error = ref<string | null>(null)\nconst isLoading = ref(false)\n\nconst handleUpdatePassword = async () => {\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.updateUser({\n password: password.value,\n })\n if (supabaseError) throw supabaseError\n // Redirect user after successful password update\n location.href = \"/protected\"\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>Please enter your new password below.</CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit.prevent=\"handleUpdatePassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"password\">New password</Label>\n <Input\n id=\"password\"\n type=\"password\"\n placeholder=\"New password\"\n required\n v-model=\"password\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Saving...\" : \"Save new password\" }}\n </Button>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/components/update-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/login.vue",+ "content": "<script setup lang=\"ts\">\nimport LoginForm from \"@/components/login-form.vue\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <LoginForm />\n </div>\n </div>\n</template>",+ "type": "registry:file",+ "target": "app/pages/auth/login.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up.vue",+ "content": "<script setup lang=\"ts\">\nimport SignUpForm from \"@/components/sign-up-form.vue\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <SignUpForm />\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/forgot-password.vue",+ "content": "<script setup lang=\"ts\">\nimport ForgotPasswordForm from \"@/components/forgot-password-form.vue\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <ForgotPasswordForm />\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/auth/forgot-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/update-password.vue",+ "content": "<script setup lang=\"ts\">\nimport UpdatePasswordForm from \"@/components/update-password-form.vue\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <UpdatePasswordForm />\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/auth/update-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/error.vue",+ "content": "<script setup lang=\"ts\">\nimport { useRoute } from \"vue-router\"\nimport { computed } from \"vue\"\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\"\n\nconst route = useRoute()\nconst errorMessage = computed(() => route.query.error as string || null)\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <div class=\"flex flex-col gap-6\">\n <Card>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Sorry, something went wrong.</CardTitle>\n </CardHeader>\n <CardContent>\n <p v-if=\"errorMessage\" class=\"text-sm text-muted-foreground\">\n Code error: {{ errorMessage }}\n </p>\n <p v-else class=\"text-sm text-muted-foreground\">\n An unspecified error occurred.\n </p>\n </CardContent>\n </Card>\n </div>\n </div>\n </div>\n</template>",+ "type": "registry:file",+ "target": "app/pages/auth/error.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up-success.vue",+ "content": "<script setup lang=\"ts\">\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\n</script>\n\n<template>\n <div class=\"flex min-h-screen w-full items-center justify-center p-6 md:p-10\">\n <div class=\"w-full max-w-sm\">\n <div class=\"flex flex-col gap-6\">\n <Card>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Thank you for signing up!</CardTitle>\n <CardDescription>Check your email to confirm</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n You’ve successfully signed up. Please check your email to confirm your account\n before signing in.\n </p>\n </CardContent>\n </Card>\n </div>\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up-success.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/protected/index.vue",+ "content": "<script setup lang=\"ts\">\nimport { onMounted, ref } from \"vue\"\nimport { useRouter } from \"vue-router\"\nimport { createClient } from \"@/lib/supabase/client\"\n\nconst router = useRouter()\nconst supabase = createClient()\nconst email = ref<string | null>(null)\nconst loading = ref(true)\n\nonMounted(async () => {\n const { data, error } = await supabase.auth.getUser()\n\n if (error || !data?.user) {\n router.replace(\"/auth/login\")\n return\n }\n\n email.value = data.user.email\n loading.value = false\n})\n\nconst handleLogout = async () => {\n await supabase.auth.signOut()\n router.replace(\"/auth/login\")\n}\n</script>\n\n<template>\n <div class=\"flex h-screen w-full items-center justify-center\">\n <div v-if=\"loading\" class=\"text-muted-foreground\">Checking authentication...</div>\n\n <div v-else class=\"flex items-center gap-2\">\n <p>\n Hello <span class=\"font-semibold\">{{ email }}</span>\n </p>\n <button\n class=\"rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium hover:bg-primary/90\"\n @click=\"handleLogout\"\n >\n Logout\n </button>\n </div>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "app/pages/protected/index.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/server/routes/auth/confirm.get.ts",+ "content": "import { createSupabaseServerClient } from '../../supabase/client'\nimport { getQuery, defineEventHandler, sendRedirect } from 'h3';\nimport type { EmailOtpType } from \"@supabase/supabase-js\"\n\nexport default defineEventHandler(async (event) => {\n const query = getQuery(event)\n const token_hash = query.token_hash as string | null\n const type = query.type as EmailOtpType | null\n const _next = query.next as string | undefined\n const next = _next?.startsWith(\"/\") ? _next : \"/\"\n\n if (token_hash && type) {\n const supabase = createSupabaseServerClient(event)\n\n const { error } = await supabase.auth.verifyOtp({\n type,\n token_hash,\n })\n\n if (!error) {\n return sendRedirect(event, next)\n } else {\n return sendRedirect(\n event,\n `/auth/error?error=${encodeURIComponent(error.message)}`\n )\n }\n }\n\n return sendRedirect(\n event,\n `/auth/error?error=${encodeURIComponent(\"No token hash or type\")}`\n )\n})",+ "type": "registry:file",+ "target": "server/routes/auth/confirm.get.ts"+ }+ ],+ "envVars": {+ "NUXT_PUBLIC_SUPABASE_URL": "",+ "NUXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY": ""+ },+ "docs": "You'll need to set the following environment variables in your project: `NUXT_PUBLIC_SUPABASE_URL` and `NUXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY`."+}\ No newline at end of filediff --git a/blocks/vue/public/r/password-based-auth-vue.json b/blocks/vue/public/r/password-based-auth-vue.jsonnew file mode 100644index 00000000000..7a54f1ff83c--- /dev/null+++ b/blocks/vue/public/r/password-based-auth-vue.json@@ -0,0 +1,42 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "password-based-auth-vue",+ "type": "registry:block",+ "title": "Password Based Auth flow for Vue and Supabase",+ "description": "Password Based Auth flow for Vue and Supabase",+ "dependencies": [+ "@supabase/supabase-js@latest"+ ],+ "registryDependencies": [+ "button",+ "card",+ "input",+ "label"+ ],+ "files": [+ {+ "path": "registry/default/password-based-auth/vue/components/login-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst email = ref(\"\")\nconst error = ref<string | null>(null)\nconst success = ref(false)\nconst isLoading = ref(false)\n\nconst handleForgotPassword = async (e: Event) => {\n e.preventDefault()\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {\n redirectTo: \"http://localhost:3000/update-password\",\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset email.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit=\"handleForgotPassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Sending...\" : \"Send reset email\" }}\n </Button>\n </div>\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "components/login-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/sign-up-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst email = ref(\"\")\nconst password = ref(\"\")\nconst repeatPassword = ref(\"\")\nconst error = ref<string | null>(null)\nconst isLoading = ref(false)\nconst success = ref(false)\n\nconst handleSignUp = async () => {\n const supabase = createClient()\n error.value = null\n\n if (password.value !== repeatPassword.value) {\n error.value = \"Passwords do not match\"\n return\n }\n\n isLoading.value = true\n try {\n const { error: supabaseError } = await supabase.auth.signUp({\n email: email.value,\n password: password.value,\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Thank you for signing up!</CardTitle>\n <CardDescription>Check your email to confirm</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n You've successfully signed up. Please check your email to confirm your account before\n signing in.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Sign up</CardTitle>\n <CardDescription>Create a new account</CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit.prevent=\"handleSignUp\">\n <div class=\"flex flex-col gap-6\">\n <!-- Email -->\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n\n <!-- Password -->\n <div class=\"grid gap-2\">\n <div class=\"flex items-center\">\n <Label for=\"password\">Password</Label>\n </div>\n <Input\n id=\"password\"\n type=\"password\"\n required\n v-model=\"password\"\n />\n </div>\n\n <!-- Repeat Password -->\n <div class=\"grid gap-2\">\n <div class=\"flex items-center\">\n <Label for=\"repeat-password\">Repeat Password</Label>\n </div>\n <Input\n id=\"repeat-password\"\n type=\"password\"\n required\n v-model=\"repeatPassword\"\n />\n </div>\n\n <!-- Error -->\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n\n <!-- Submit -->\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Creating an account...\" : \"Sign up\" }}\n </Button>\n </div>\n\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "components/sign-up-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/forgot-password-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\n\nconst email = ref(\"\")\nconst error = ref<string | null>(null)\nconst success = ref(false)\nconst isLoading = ref(false)\n\nconst handleForgotPassword = async (e: Event) => {\n e.preventDefault()\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {\n redirectTo: \"http://localhost:3000/update-password\",\n })\n if (supabaseError) throw supabaseError\n success.value = true\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card v-if=\"success\">\n <CardHeader>\n <CardTitle class=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p class=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset email.\n </p>\n </CardContent>\n </Card>\n\n <Card v-else>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit=\"handleForgotPassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n v-model=\"email\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Sending...\" : \"Send reset email\" }}\n </Button>\n </div>\n <div class=\"mt-4 text-center text-sm\">\n Already have an account?\n <a href=\"/login\" class=\"underline underline-offset-4\">Login</a>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "components/forgot-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/update-password-form.vue",+ "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\"\nimport { createClient } from \"@/lib/supabase/client\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\n\nconst password = ref(\"\")\nconst error = ref<string | null>(null)\nconst isLoading = ref(false)\n\nconst handleUpdatePassword = async () => {\n const supabase = createClient()\n isLoading.value = true\n error.value = null\n\n try {\n const { error: supabaseError } = await supabase.auth.updateUser({\n password: password.value,\n })\n if (supabaseError) throw supabaseError\n // Redirect user after successful password update\n location.href = \"/protected\"\n } catch (err: unknown) {\n error.value = err instanceof Error ? err.message : \"An error occurred\"\n } finally {\n isLoading.value = false\n }\n}\n</script>\n\n<template>\n <div class=\"flex flex-col gap-6\">\n <Card>\n <CardHeader>\n <CardTitle class=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>Please enter your new password below.</CardDescription>\n </CardHeader>\n <CardContent>\n <form @submit.prevent=\"handleUpdatePassword\">\n <div class=\"flex flex-col gap-6\">\n <div class=\"grid gap-2\">\n <Label for=\"password\">New password</Label>\n <Input\n id=\"password\"\n type=\"password\"\n placeholder=\"New password\"\n required\n v-model=\"password\"\n />\n </div>\n <p v-if=\"error\" class=\"text-sm text-red-500\">{{ error }}</p>\n <Button type=\"submit\" class=\"w-full\" :disabled=\"isLoading\">\n {{ isLoading ? \"Saving...\" : \"Save new password\" }}\n </Button>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n</template>\n",+ "type": "registry:file",+ "target": "components/update-password-form.vue"+ }+ ]+}\ No newline at end of filediff --git a/blocks/vue/registry.json b/blocks/vue/registry.jsonindex 72133a53e50..7b719fbc10e 100644--- a/blocks/vue/registry.json+++ b/blocks/vue/registry.json@@ -57,6 +57,112 @@"type": "registry:lib"}]+ },+ {+ "name": "password-based-auth-vue",+ "type": "registry:block",+ "title": "Password Based Auth flow for Vue and Supabase",+ "description": "Password Based Auth flow for Vue and Supabase",+ "registryDependencies": ["button", "card", "input", "label"],+ "files": [+ {+ "path": "registry/default/password-based-auth/vue/components/login-form.vue",+ "type": "registry:file",+ "target": "components/login-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/sign-up-form.vue",+ "type": "registry:file",+ "target": "components/sign-up-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/forgot-password-form.vue",+ "type": "registry:file",+ "target": "components/forgot-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/update-password-form.vue",+ "type": "registry:file",+ "target": "components/update-password-form.vue"+ }+ ],+ "dependencies": ["@supabase/supabase-js@latest"]+ },+ {+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "password-based-auth-nuxtjs",+ "type": "registry:lib",+ "title": "Password Based Auth flow for Nuxt.js and Supabase",+ "description": "",+ "registryDependencies": ["button", "card", "input", "label"],+ "dependencies": ["@supabase/ssr@latest", "@supabase/supabase-js@latest"],+ "docs": "You'll need to set the following environment variables in your project: `NUXT_PUBLIC_SUPABASE_URL` and `NUXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY`.",+ "envVars": {+ "NUXT_PUBLIC_SUPABASE_URL": "",+ "NUXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY": ""+ },+ "files": [+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/login-form.vue",+ "type": "registry:file",+ "target": "app/components/login-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/sign-up-form.vue",+ "type": "registry:file",+ "target": "app/components/sign-up-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/forgot-password-form.vue",+ "type": "registry:file",+ "target": "app/components/forgot-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/update-password-form.vue",+ "type": "registry:file",+ "target": "app/components/update-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/login.vue",+ "type": "registry:file",+ "target": "app/pages/auth/login.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up.vue",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/forgot-password.vue",+ "type": "registry:file",+ "target": "app/pages/auth/forgot-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/update-password.vue",+ "type": "registry:file",+ "target": "app/pages/auth/update-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/error.vue",+ "type": "registry:file",+ "target": "app/pages/auth/error.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up-success.vue",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up-success.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/protected/index.vue",+ "type": "registry:file",+ "target": "app/pages/protected/index.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/server/routes/auth/confirm.get.ts",+ "type": "registry:file",+ "target": "server/routes/auth/confirm.get.ts"+ }+ ]}]}diff --git a/blocks/vue/registry/default/components/ui/Button.vue b/blocks/vue/registry/default/components/ui/Button.vuenew file mode 100644index 00000000000..a3460f9bf70--- /dev/null+++ b/blocks/vue/registry/default/components/ui/Button.vue@@ -0,0 +1,58 @@+<script setup lang="ts">+import { computed } from "vue"+import { cva, type VariantProps } from "class-variance-authority"+import { cn } from "../../lib/utils"++const buttonVariants = cva(+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",+ {+ variants: {+ variant: {+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",+ destructive:+ "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",+ outline:+ "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",+ secondary:+ "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",+ ghost: "hover:bg-accent hover:text-accent-foreground",+ link: "text-primary underline-offset-4 hover:underline",+ },+ size: {+ default: "h-9 px-4 py-2",+ sm: "h-8 rounded-md px-3 text-xs",+ lg: "h-10 rounded-md px-8",+ icon: "h-9 w-9",+ },+ },+ defaultVariants: {+ variant: "default",+ size: "default",+ },+ }+)++type ButtonVariants = VariantProps<typeof buttonVariants>++defineProps<{+ variant?: ButtonVariants["variant"]+ size?: ButtonVariants["size"]+ as?: string+}>()++const props = defineProps<{+ variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link"+ size?: "default" | "sm" | "lg" | "icon"+ as?: string+}>()++const buttonClass = computed(() =>+ cn(buttonVariants({ variant: props.variant, size: props.size }))+)+</script>++<template>+ <component :is="as" :class="buttonClass">+ <slot />+ </component>+</template>diff --git a/blocks/vue/registry/default/components/ui/Input.vue b/blocks/vue/registry/default/components/ui/Input.vuenew file mode 100644index 00000000000..e76386bc7e8--- /dev/null+++ b/blocks/vue/registry/default/components/ui/Input.vue@@ -0,0 +1,25 @@+<script setup lang="ts">+import { cn } from "../../lib/utils"++defineProps<{+ type?: string+ class?: string+}>()++const props = defineProps({+ type: { type: String, default: "text" },+ class: { type: String, default: "" },+})+</script>++<template>+ <input+ :type="props.type"+ :class="+ cn(+ 'flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',+ props.class+ )+ "+ />+</template>diff --git a/blocks/vue/registry/default/components/ui/Label.vue b/blocks/vue/registry/default/components/ui/Label.vuenew file mode 100644index 00000000000..088ab2cb8a3--- /dev/null+++ b/blocks/vue/registry/default/components/ui/Label.vue@@ -0,0 +1,28 @@+<script setup lang="ts">+import { cva, type VariantProps } from "class-variance-authority"+import { cn } from "../../lib/utils"++const labelVariants = cva(+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"+)++type LabelVariants = VariantProps<typeof labelVariants>++defineProps<{+ as?: string+ class?: string+}>()++const props = defineProps({+ as: { type: String, default: "label" },+ class: { type: String, default: "" },+})++const labelClass = cn(labelVariants(), props.class)+</script>++<template>+ <component :is="as" :class="labelClass">+ <slot />+ </component>+</template>diff --git a/blocks/vue/registry/default/components/ui/card/Card.vue b/blocks/vue/registry/default/components/ui/card/Card.vuenew file mode 100644index 00000000000..9e8c57b0f3b--- /dev/null+++ b/blocks/vue/registry/default/components/ui/card/Card.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import { cn } from "../../../lib/utils"++defineProps<{ class?: string }>()+</script>++<template>+ <div :class="cn('rounded-xl border bg-card text-card-foreground shadow', $props.class)">+ <slot />+ </div>+</template>diff --git a/blocks/vue/registry/default/components/ui/card/CardContent.vue b/blocks/vue/registry/default/components/ui/card/CardContent.vuenew file mode 100644index 00000000000..21fe39e6b71--- /dev/null+++ b/blocks/vue/registry/default/components/ui/card/CardContent.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import { cn } from "../../../lib/utils"++defineProps<{ class?: string }>()+</script>++<template>+ <div :class="cn('p-6 pt-0', $props.class)">+ <slot />+ </div>+</template>diff --git a/blocks/vue/registry/default/components/ui/card/CardDescription.vue b/blocks/vue/registry/default/components/ui/card/CardDescription.vuenew file mode 100644index 00000000000..9eb050b7758--- /dev/null+++ b/blocks/vue/registry/default/components/ui/card/CardDescription.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import { cn } from "../../../lib/utils"++defineProps<{ class?: string }>()+</script>++<template>+ <div :class="cn('text-sm text-muted-foreground', $props.class)">+ <slot />+ </div>+</template>diff --git a/blocks/vue/registry/default/components/ui/card/CardFooter.vue b/blocks/vue/registry/default/components/ui/card/CardFooter.vuenew file mode 100644index 00000000000..e058eee8004--- /dev/null+++ b/blocks/vue/registry/default/components/ui/card/CardFooter.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import { cn } from "../../../lib/utils"++defineProps<{ class?: string }>()+</script>++<template>+ <div :class="cn('flex items-center p-6 pt-0', $props.class)">+ <slot />+ </div>+</template>diff --git a/blocks/vue/registry/default/components/ui/card/CardHeader.vue b/blocks/vue/registry/default/components/ui/card/CardHeader.vuenew file mode 100644index 00000000000..17edde4906c--- /dev/null+++ b/blocks/vue/registry/default/components/ui/card/CardHeader.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import { cn } from "../../../lib/utils"++defineProps<{ class?: string }>()+</script>++<template>+ <div :class="cn('flex flex-col space-y-1.5 p-6', $props.class)">+ <slot />+ </div>+</template>diff --git a/blocks/vue/registry/default/components/ui/card/CardTitle.vue b/blocks/vue/registry/default/components/ui/card/CardTitle.vuenew file mode 100644index 00000000000..509a5d8e65f--- /dev/null+++ b/blocks/vue/registry/default/components/ui/card/CardTitle.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import { cn } from "../../../lib/utils"++defineProps<{ class?: string }>()+</script>++<template>+ <div :class="cn('font-semibold leading-none tracking-tight', $props.class)">+ <slot />+ </div>+</template>diff --git a/blocks/vue/registry/default/lib/utils.ts b/blocks/vue/registry/default/lib/utils.tsnew file mode 100644index 00000000000..951433cb3b3--- /dev/null+++ b/blocks/vue/registry/default/lib/utils.ts@@ -0,0 +1,7 @@+import type { ClassValue } from "clsx"+import { clsx } from "clsx"+import { twMerge } from "tailwind-merge"++export function cn(...inputs: ClassValue[]) {+ return twMerge(clsx(inputs))+}\ No newline at end of filediff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/forgot-password-form.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/forgot-password-form.vuenew file mode 100644index 00000000000..d40c5cfa521--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/forgot-password-form.vue@@ -0,0 +1,88 @@+<script setup lang="ts">+import { ref } from "vue"+import { createClient } from "@/lib/supabase/client"+import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { Input } from "@/components/ui/input"+import { Label } from "@/components/ui/label"+++const email = ref("")+const error = ref<string | null>(null)+const success = ref(false)+const isLoading = ref(false)++const handleForgotPassword = async (e: Event) => {+ e.preventDefault()+ const supabase = createClient()+ isLoading.value = true+ error.value = null++ try {+ const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {+ redirectTo: "http://localhost:3000/update-password",+ })+ if (supabaseError) throw supabaseError+ success.value = true+ } catch (err: unknown) {+ error.value = err instanceof Error ? err.message : "An error occurred"+ } finally {+ isLoading.value = false+ }+}+</script>++<template>+ <div class="flex flex-col gap-6">+ <Card v-if="success">+ <CardHeader>+ <CardTitle class="text-2xl">Check Your Email</CardTitle>+ <CardDescription>Password reset instructions sent</CardDescription>+ </CardHeader>+ <CardContent>+ <p class="text-sm text-muted-foreground">+ If you registered using your email and password, you will receive a password reset email.+ </p>+ </CardContent>+ </Card>++ <Card v-else>+ <CardHeader>+ <CardTitle class="text-2xl">Reset Your Password</CardTitle>+ <CardDescription>+ Type in your email and we'll send you a link to reset your password+ </CardDescription>+ </CardHeader>+ <CardContent>+ <form @submit="handleForgotPassword">+ <div class="flex flex-col gap-6">+ <div class="grid gap-2">+ <Label for="email">Email</Label>+ <Input+ id="email"+ type="email"+ placeholder="[email protected]"+ required+ v-model="email"+ />+ </div>+ <p v-if="error" class="text-sm text-red-500">{{ error }}</p>+ <Button type="submit" class="w-full" :disabled="isLoading">+ {{ isLoading ? "Sending..." : "Send reset email" }}+ </Button>+ </div>+ <div class="mt-4 text-center text-sm">+ Already have an account?+ <a href="/login" class="underline underline-offset-4">Login</a>+ </div>+ </form>+ </CardContent>+ </Card>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/login-form.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/login-form.vuenew file mode 100644index 00000000000..79e868c0600--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/login-form.vue@@ -0,0 +1,87 @@+<script setup lang="ts">+import { ref } from "vue"+import { createClient } from "@/lib/supabase/client"+import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { Input } from "@/components/ui/input"+import { Label } from "@/components/ui/label"++const email = ref("")+const error = ref<string | null>(null)+const success = ref(false)+const isLoading = ref(false)++const handleForgotPassword = async (e: Event) => {+ e.preventDefault()+ const supabase = createClient()+ isLoading.value = true+ error.value = null++ try {+ const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {+ redirectTo: "http://localhost:3000/update-password",+ })+ if (supabaseError) throw supabaseError+ success.value = true+ } catch (err: unknown) {+ error.value = err instanceof Error ? err.message : "An error occurred"+ } finally {+ isLoading.value = false+ }+}+</script>++<template>+ <div class="flex flex-col gap-6">+ <Card v-if="success">+ <CardHeader>+ <CardTitle class="text-2xl">Check Your Email</CardTitle>+ <CardDescription>Password reset instructions sent</CardDescription>+ </CardHeader>+ <CardContent>+ <p class="text-sm text-muted-foreground">+ If you registered using your email and password, you will receive a password reset email.+ </p>+ </CardContent>+ </Card>++ <Card v-else>+ <CardHeader>+ <CardTitle class="text-2xl">Reset Your Password</CardTitle>+ <CardDescription>+ Type in your email and we'll send you a link to reset your password+ </CardDescription>+ </CardHeader>+ <CardContent>+ <form @submit="handleForgotPassword">+ <div class="flex flex-col gap-6">+ <div class="grid gap-2">+ <Label for="email">Email</Label>+ <Input+ id="email"+ type="email"+ placeholder="[email protected]"+ required+ v-model="email"+ />+ </div>+ <p v-if="error" class="text-sm text-red-500">{{ error }}</p>+ <Button type="submit" class="w-full" :disabled="isLoading">+ {{ isLoading ? "Sending..." : "Send reset email" }}+ </Button>+ </div>+ <div class="mt-4 text-center text-sm">+ Already have an account?+ <a href="/login" class="underline underline-offset-4">Login</a>+ </div>+ </form>+ </CardContent>+ </Card>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/sign-up-form.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/sign-up-form.vuenew file mode 100644index 00000000000..9a15f32197d--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/sign-up-form.vue@@ -0,0 +1,125 @@+<script setup lang="ts">+import { ref } from "vue"+import { createClient } from "@/lib/supabase/client"+import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { Input } from "@/components/ui/input"+import { Label } from "@/components/ui/label"++const email = ref("")+const password = ref("")+const repeatPassword = ref("")+const error = ref<string | null>(null)+const isLoading = ref(false)+const success = ref(false)++const handleSignUp = async () => {+ const supabase = createClient()+ error.value = null++ if (password.value !== repeatPassword.value) {+ error.value = "Passwords do not match"+ return+ }++ isLoading.value = true+ try {+ const { error: supabaseError } = await supabase.auth.signUp({+ email: email.value,+ password: password.value,+ })+ if (supabaseError) throw supabaseError+ success.value = true+ } catch (err: unknown) {+ error.value = err instanceof Error ? err.message : "An error occurred"+ } finally {+ isLoading.value = false+ }+}+</script>++<template>+ <div class="flex flex-col gap-6">+ <Card v-if="success">+ <CardHeader>+ <CardTitle class="text-2xl">Thank you for signing up!</CardTitle>+ <CardDescription>Check your email to confirm</CardDescription>+ </CardHeader>+ <CardContent>+ <p class="text-sm text-muted-foreground">+ You've successfully signed up. Please check your email to confirm your account before+ signing in.+ </p>+ </CardContent>+ </Card>++ <Card v-else>+ <CardHeader>+ <CardTitle class="text-2xl">Sign up</CardTitle>+ <CardDescription>Create a new account</CardDescription>+ </CardHeader>+ <CardContent>+ <form @submit.prevent="handleSignUp">+ <div class="flex flex-col gap-6">+ <!-- Email -->+ <div class="grid gap-2">+ <Label for="email">Email</Label>+ <Input+ id="email"+ type="email"+ placeholder="[email protected]"+ required+ v-model="email"+ />+ </div>++ <!-- Password -->+ <div class="grid gap-2">+ <div class="flex items-center">+ <Label for="password">Password</Label>+ </div>+ <Input+ id="password"+ type="password"+ required+ v-model="password"+ />+ </div>++ <!-- Repeat Password -->+ <div class="grid gap-2">+ <div class="flex items-center">+ <Label for="repeat-password">Repeat Password</Label>+ </div>+ <Input+ id="repeat-password"+ type="password"+ required+ v-model="repeatPassword"+ />+ </div>++ <!-- Error -->+ <p v-if="error" class="text-sm text-red-500">{{ error }}</p>++ <!-- Submit -->+ <Button type="submit" class="w-full" :disabled="isLoading">+ {{ isLoading ? "Creating an account..." : "Sign up" }}+ </Button>+ </div>++ <div class="mt-4 text-center text-sm">+ Already have an account?+ <a href="/login" class="underline underline-offset-4">Login</a>+ </div>+ </form>+ </CardContent>+ </Card>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/update-password-form.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/update-password-form.vuenew file mode 100644index 00000000000..fae48a10c99--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/components/update-password-form.vue@@ -0,0 +1,68 @@+<script setup lang="ts">+import { ref } from "vue"+import { createClient } from "@/lib/supabase/client"+import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { Input } from "@/components/ui/input"+import { Label } from "@/components/ui/label"++const password = ref("")+const error = ref<string | null>(null)+const isLoading = ref(false)++const handleUpdatePassword = async () => {+ const supabase = createClient()+ isLoading.value = true+ error.value = null++ try {+ const { error: supabaseError } = await supabase.auth.updateUser({+ password: password.value,+ })+ if (supabaseError) throw supabaseError+ // Redirect user after successful password update+ location.href = "/protected"+ } catch (err: unknown) {+ error.value = err instanceof Error ? err.message : "An error occurred"+ } finally {+ isLoading.value = false+ }+}+</script>++<template>+ <div class="flex flex-col gap-6">+ <Card>+ <CardHeader>+ <CardTitle class="text-2xl">Reset Your Password</CardTitle>+ <CardDescription>Please enter your new password below.</CardDescription>+ </CardHeader>+ <CardContent>+ <form @submit.prevent="handleUpdatePassword">+ <div class="flex flex-col gap-6">+ <div class="grid gap-2">+ <Label for="password">New password</Label>+ <Input+ id="password"+ type="password"+ placeholder="New password"+ required+ v-model="password"+ />+ </div>+ <p v-if="error" class="text-sm text-red-500">{{ error }}</p>+ <Button type="submit" class="w-full" :disabled="isLoading">+ {{ isLoading ? "Saving..." : "Save new password" }}+ </Button>+ </div>+ </form>+ </CardContent>+ </Card>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/error.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/error.vuenew file mode 100644index 00000000000..966dea5d7c4--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/error.vue@@ -0,0 +1,30 @@+<script setup lang="ts">+import { useRoute } from "vue-router"+import { computed } from "vue"+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"++const route = useRoute()+const errorMessage = computed(() => route.query.error as string || null)+</script>++<template>+ <div class="flex min-h-screen w-full items-center justify-center p-6 md:p-10">+ <div class="w-full max-w-sm">+ <div class="flex flex-col gap-6">+ <Card>+ <CardHeader>+ <CardTitle class="text-2xl">Sorry, something went wrong.</CardTitle>+ </CardHeader>+ <CardContent>+ <p v-if="errorMessage" class="text-sm text-muted-foreground">+ Code error: {{ errorMessage }}+ </p>+ <p v-else class="text-sm text-muted-foreground">+ An unspecified error occurred.+ </p>+ </CardContent>+ </Card>+ </div>+ </div>+ </div>+</template>\ No newline at end of filediff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/forgot-password.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/forgot-password.vuenew file mode 100644index 00000000000..34d0fefce28--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/forgot-password.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import ForgotPasswordForm from "@/components/forgot-password-form.vue"+</script>++<template>+ <div class="flex min-h-screen w-full items-center justify-center p-6 md:p-10">+ <div class="w-full max-w-sm">+ <ForgotPasswordForm />+ </div>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/login.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/login.vuenew file mode 100644index 00000000000..76bdef58a23--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/login.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import LoginForm from "@/components/login-form.vue"+</script>++<template>+ <div class="flex min-h-screen w-full items-center justify-center p-6 md:p-10">+ <div class="w-full max-w-sm">+ <LoginForm />+ </div>+ </div>+</template>\ No newline at end of filediff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up-success.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up-success.vuenew file mode 100644index 00000000000..f9ae9959bfe--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up-success.vue@@ -0,0 +1,30 @@+<script setup lang="ts">+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+</script>++<template>+ <div class="flex min-h-screen w-full items-center justify-center p-6 md:p-10">+ <div class="w-full max-w-sm">+ <div class="flex flex-col gap-6">+ <Card>+ <CardHeader>+ <CardTitle class="text-2xl">Thank you for signing up!</CardTitle>+ <CardDescription>Check your email to confirm</CardDescription>+ </CardHeader>+ <CardContent>+ <p class="text-sm text-muted-foreground">+ You’ve successfully signed up. Please check your email to confirm your account+ before signing in.+ </p>+ </CardContent>+ </Card>+ </div>+ </div>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up.vuenew file mode 100644index 00000000000..114526443b2--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import SignUpForm from "@/components/sign-up-form.vue"+</script>++<template>+ <div class="flex min-h-screen w-full items-center justify-center p-6 md:p-10">+ <div class="w-full max-w-sm">+ <SignUpForm />+ </div>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/update-password.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/update-password.vuenew file mode 100644index 00000000000..d325e4665b3--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/auth/update-password.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import UpdatePasswordForm from "@/components/update-password-form.vue"+</script>++<template>+ <div class="flex min-h-screen w-full items-center justify-center p-6 md:p-10">+ <div class="w-full max-w-sm">+ <UpdatePasswordForm />+ </div>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/protected/index.vue b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/protected/index.vuenew file mode 100644index 00000000000..c21be7818bc--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/app/pages/protected/index.vue@@ -0,0 +1,45 @@+<script setup lang="ts">+import { onMounted, ref } from "vue"+import { useRouter } from "vue-router"+import { createClient } from "@/lib/supabase/client"++const router = useRouter()+const supabase = createClient()+const email = ref<string | null>(null)+const loading = ref(true)++onMounted(async () => {+ const { data, error } = await supabase.auth.getUser()++ if (error || !data?.user) {+ router.replace("/auth/login")+ return+ }++ email.value = data.user.email+ loading.value = false+})++const handleLogout = async () => {+ await supabase.auth.signOut()+ router.replace("/auth/login")+}+</script>++<template>+ <div class="flex h-screen w-full items-center justify-center">+ <div v-if="loading" class="text-muted-foreground">Checking authentication...</div>++ <div v-else class="flex items-center gap-2">+ <p>+ Hello <span class="font-semibold">{{ email }}</span>+ </p>+ <button+ class="rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium hover:bg-primary/90"+ @click="handleLogout"+ >+ Logout+ </button>+ </div>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/registry-item.json b/blocks/vue/registry/default/password-based-auth/nuxtjs/registry-item.jsonnew file mode 100644index 00000000000..fcdc981a7ca--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/registry-item.json@@ -0,0 +1,70 @@+{+ "name": "password-based-auth-nuxtjs",+ "type": "registry:block",+ "title": "Password Based Auth flow for Nuxt.js and Supabase",+ "description": "Password Based Auth flow for Nuxt.js and Supabase",+ "registryDependencies": ["button", "card", "input", "label"],+ "dependencies": ["@supabase/ssr@latest", "@supabase/supabase-js@latest"],+ "files": [+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/login-form.vue",+ "type": "registry:file",+ "target": "app/components/login-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/sign-up-form.vue",+ "type": "registry:file",+ "target": "app/components/sign-up-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/forgot-password-form.vue",+ "type": "registry:file",+ "target": "app/components/forgot-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/components/update-password-form.vue",+ "type": "registry:file",+ "target": "app/components/update-password-form.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/login.vue",+ "type": "registry:file",+ "target": "app/pages/auth/login.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up.vue",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/forgot-password.vue",+ "type": "registry:file",+ "target": "app/pages/auth/forgot-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/update-password.vue",+ "type": "registry:file",+ "target": "app/pages/auth/update-password.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/error.vue",+ "type": "registry:file",+ "target": "app/pages/auth/error.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/auth/sign-up-success.vue",+ "type": "registry:file",+ "target": "app/pages/auth/sign-up-success.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/app/pages/protected/index.vue",+ "type": "registry:file",+ "target": "app/pages/protected/index.vue"+ },+ {+ "path": "registry/default/password-based-auth/nuxtjs/server/routes/auth/confirm.get.ts",+ "type": "registry:file",+ "target": "server/routes/auth/confirm.get.ts"+ }+ ]+}diff --git a/blocks/vue/registry/default/password-based-auth/nuxtjs/server/routes/auth/confirm.get.ts b/blocks/vue/registry/default/password-based-auth/nuxtjs/server/routes/auth/confirm.get.tsnew file mode 100644index 00000000000..c6f18dfecad--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/nuxtjs/server/routes/auth/confirm.get.ts@@ -0,0 +1,28 @@+import { getQuery, defineEventHandler, sendRedirect } from 'h3'+import type { EmailOtpType } from '@supabase/supabase-js'+import { createSupabaseServerClient } from '@/registry/default/clients/nuxtjs/server/supabase/client'++export default defineEventHandler(async (event) => {+ const query = getQuery(event)+ const token_hash = query.token_hash as string | null+ const type = query.type as EmailOtpType | null+ const _next = query.next as string | undefined+ const next = _next?.startsWith('/') ? _next : '/'++ if (token_hash && type) {+ const supabase = createSupabaseServerClient(event)++ const { error } = await supabase.auth.verifyOtp({+ type,+ token_hash,+ })++ if (!error) {+ return sendRedirect(event, next)+ } else {+ return sendRedirect(event, `/auth/error?error=${encodeURIComponent(error.message)}`)+ }+ }++ return sendRedirect(event, `/auth/error?error=${encodeURIComponent('No token hash or type')}`)+})diff --git a/blocks/vue/registry/default/password-based-auth/vue/components/forgot-password-form.vue b/blocks/vue/registry/default/password-based-auth/vue/components/forgot-password-form.vuenew file mode 100644index 00000000000..d40c5cfa521--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/vue/components/forgot-password-form.vue@@ -0,0 +1,88 @@+<script setup lang="ts">+import { ref } from "vue"+import { createClient } from "@/lib/supabase/client"+import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { Input } from "@/components/ui/input"+import { Label } from "@/components/ui/label"+++const email = ref("")+const error = ref<string | null>(null)+const success = ref(false)+const isLoading = ref(false)++const handleForgotPassword = async (e: Event) => {+ e.preventDefault()+ const supabase = createClient()+ isLoading.value = true+ error.value = null++ try {+ const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {+ redirectTo: "http://localhost:3000/update-password",+ })+ if (supabaseError) throw supabaseError+ success.value = true+ } catch (err: unknown) {+ error.value = err instanceof Error ? err.message : "An error occurred"+ } finally {+ isLoading.value = false+ }+}+</script>++<template>+ <div class="flex flex-col gap-6">+ <Card v-if="success">+ <CardHeader>+ <CardTitle class="text-2xl">Check Your Email</CardTitle>+ <CardDescription>Password reset instructions sent</CardDescription>+ </CardHeader>+ <CardContent>+ <p class="text-sm text-muted-foreground">+ If you registered using your email and password, you will receive a password reset email.+ </p>+ </CardContent>+ </Card>++ <Card v-else>+ <CardHeader>+ <CardTitle class="text-2xl">Reset Your Password</CardTitle>+ <CardDescription>+ Type in your email and we'll send you a link to reset your password+ </CardDescription>+ </CardHeader>+ <CardContent>+ <form @submit="handleForgotPassword">+ <div class="flex flex-col gap-6">+ <div class="grid gap-2">+ <Label for="email">Email</Label>+ <Input+ id="email"+ type="email"+ placeholder="[email protected]"+ required+ v-model="email"+ />+ </div>+ <p v-if="error" class="text-sm text-red-500">{{ error }}</p>+ <Button type="submit" class="w-full" :disabled="isLoading">+ {{ isLoading ? "Sending..." : "Send reset email" }}+ </Button>+ </div>+ <div class="mt-4 text-center text-sm">+ Already have an account?+ <a href="/login" class="underline underline-offset-4">Login</a>+ </div>+ </form>+ </CardContent>+ </Card>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/vue/components/login-form.vue b/blocks/vue/registry/default/password-based-auth/vue/components/login-form.vuenew file mode 100644index 00000000000..79e868c0600--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/vue/components/login-form.vue@@ -0,0 +1,87 @@+<script setup lang="ts">+import { ref } from "vue"+import { createClient } from "@/lib/supabase/client"+import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { Input } from "@/components/ui/input"+import { Label } from "@/components/ui/label"++const email = ref("")+const error = ref<string | null>(null)+const success = ref(false)+const isLoading = ref(false)++const handleForgotPassword = async (e: Event) => {+ e.preventDefault()+ const supabase = createClient()+ isLoading.value = true+ error.value = null++ try {+ const { error: supabaseError } = await supabase.auth.resetPasswordForEmail(email.value, {+ redirectTo: "http://localhost:3000/update-password",+ })+ if (supabaseError) throw supabaseError+ success.value = true+ } catch (err: unknown) {+ error.value = err instanceof Error ? err.message : "An error occurred"+ } finally {+ isLoading.value = false+ }+}+</script>++<template>+ <div class="flex flex-col gap-6">+ <Card v-if="success">+ <CardHeader>+ <CardTitle class="text-2xl">Check Your Email</CardTitle>+ <CardDescription>Password reset instructions sent</CardDescription>+ </CardHeader>+ <CardContent>+ <p class="text-sm text-muted-foreground">+ If you registered using your email and password, you will receive a password reset email.+ </p>+ </CardContent>+ </Card>++ <Card v-else>+ <CardHeader>+ <CardTitle class="text-2xl">Reset Your Password</CardTitle>+ <CardDescription>+ Type in your email and we'll send you a link to reset your password+ </CardDescription>+ </CardHeader>+ <CardContent>+ <form @submit="handleForgotPassword">+ <div class="flex flex-col gap-6">+ <div class="grid gap-2">+ <Label for="email">Email</Label>+ <Input+ id="email"+ type="email"+ placeholder="[email protected]"+ required+ v-model="email"+ />+ </div>+ <p v-if="error" class="text-sm text-red-500">{{ error }}</p>+ <Button type="submit" class="w-full" :disabled="isLoading">+ {{ isLoading ? "Sending..." : "Send reset email" }}+ </Button>+ </div>+ <div class="mt-4 text-center text-sm">+ Already have an account?+ <a href="/login" class="underline underline-offset-4">Login</a>+ </div>+ </form>+ </CardContent>+ </Card>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/vue/components/sign-up-form.vue b/blocks/vue/registry/default/password-based-auth/vue/components/sign-up-form.vuenew file mode 100644index 00000000000..9a15f32197d--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/vue/components/sign-up-form.vue@@ -0,0 +1,125 @@+<script setup lang="ts">+import { ref } from "vue"+import { createClient } from "@/lib/supabase/client"+import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { Input } from "@/components/ui/input"+import { Label } from "@/components/ui/label"++const email = ref("")+const password = ref("")+const repeatPassword = ref("")+const error = ref<string | null>(null)+const isLoading = ref(false)+const success = ref(false)++const handleSignUp = async () => {+ const supabase = createClient()+ error.value = null++ if (password.value !== repeatPassword.value) {+ error.value = "Passwords do not match"+ return+ }++ isLoading.value = true+ try {+ const { error: supabaseError } = await supabase.auth.signUp({+ email: email.value,+ password: password.value,+ })+ if (supabaseError) throw supabaseError+ success.value = true+ } catch (err: unknown) {+ error.value = err instanceof Error ? err.message : "An error occurred"+ } finally {+ isLoading.value = false+ }+}+</script>++<template>+ <div class="flex flex-col gap-6">+ <Card v-if="success">+ <CardHeader>+ <CardTitle class="text-2xl">Thank you for signing up!</CardTitle>+ <CardDescription>Check your email to confirm</CardDescription>+ </CardHeader>+ <CardContent>+ <p class="text-sm text-muted-foreground">+ You've successfully signed up. Please check your email to confirm your account before+ signing in.+ </p>+ </CardContent>+ </Card>++ <Card v-else>+ <CardHeader>+ <CardTitle class="text-2xl">Sign up</CardTitle>+ <CardDescription>Create a new account</CardDescription>+ </CardHeader>+ <CardContent>+ <form @submit.prevent="handleSignUp">+ <div class="flex flex-col gap-6">+ <!-- Email -->+ <div class="grid gap-2">+ <Label for="email">Email</Label>+ <Input+ id="email"+ type="email"+ placeholder="[email protected]"+ required+ v-model="email"+ />+ </div>++ <!-- Password -->+ <div class="grid gap-2">+ <div class="flex items-center">+ <Label for="password">Password</Label>+ </div>+ <Input+ id="password"+ type="password"+ required+ v-model="password"+ />+ </div>++ <!-- Repeat Password -->+ <div class="grid gap-2">+ <div class="flex items-center">+ <Label for="repeat-password">Repeat Password</Label>+ </div>+ <Input+ id="repeat-password"+ type="password"+ required+ v-model="repeatPassword"+ />+ </div>++ <!-- Error -->+ <p v-if="error" class="text-sm text-red-500">{{ error }}</p>++ <!-- Submit -->+ <Button type="submit" class="w-full" :disabled="isLoading">+ {{ isLoading ? "Creating an account..." : "Sign up" }}+ </Button>+ </div>++ <div class="mt-4 text-center text-sm">+ Already have an account?+ <a href="/login" class="underline underline-offset-4">Login</a>+ </div>+ </form>+ </CardContent>+ </Card>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/vue/components/update-password-form.vue b/blocks/vue/registry/default/password-based-auth/vue/components/update-password-form.vuenew file mode 100644index 00000000000..fae48a10c99--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/vue/components/update-password-form.vue@@ -0,0 +1,68 @@+<script setup lang="ts">+import { ref } from "vue"+import { createClient } from "@/lib/supabase/client"+import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { Input } from "@/components/ui/input"+import { Label } from "@/components/ui/label"++const password = ref("")+const error = ref<string | null>(null)+const isLoading = ref(false)++const handleUpdatePassword = async () => {+ const supabase = createClient()+ isLoading.value = true+ error.value = null++ try {+ const { error: supabaseError } = await supabase.auth.updateUser({+ password: password.value,+ })+ if (supabaseError) throw supabaseError+ // Redirect user after successful password update+ location.href = "/protected"+ } catch (err: unknown) {+ error.value = err instanceof Error ? err.message : "An error occurred"+ } finally {+ isLoading.value = false+ }+}+</script>++<template>+ <div class="flex flex-col gap-6">+ <Card>+ <CardHeader>+ <CardTitle class="text-2xl">Reset Your Password</CardTitle>+ <CardDescription>Please enter your new password below.</CardDescription>+ </CardHeader>+ <CardContent>+ <form @submit.prevent="handleUpdatePassword">+ <div class="flex flex-col gap-6">+ <div class="grid gap-2">+ <Label for="password">New password</Label>+ <Input+ id="password"+ type="password"+ placeholder="New password"+ required+ v-model="password"+ />+ </div>+ <p v-if="error" class="text-sm text-red-500">{{ error }}</p>+ <Button type="submit" class="w-full" :disabled="isLoading">+ {{ isLoading ? "Saving..." : "Save new password" }}+ </Button>+ </div>+ </form>+ </CardContent>+ </Card>+ </div>+</template>diff --git a/blocks/vue/registry/default/password-based-auth/vue/registry-item.json b/blocks/vue/registry/default/password-based-auth/vue/registry-item.jsonnew file mode 100644index 00000000000..8966e22af38--- /dev/null+++ b/blocks/vue/registry/default/password-based-auth/vue/registry-item.json@@ -0,0 +1,26 @@+{+ "name": "password-based-auth-vue",+ "type": "registry:block",+ "title": "Password Based Auth flow for Vue and Supabase",+ "description": "Password Based Auth flow for Vue and Supabase",+ "registryDependencies": ["button", "card", "input", "label"],+ "files": [+ {+ "path": "registry/default/password-based-auth/vue/components/login-form.vue",+ "type": "registry:component"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/sign-up-form.vue",+ "type": "registry:component"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/forgot-password-form.vue",+ "type": "registry:component"+ },+ {+ "path": "registry/default/password-based-auth/vue/components/update-password-form.vue",+ "type": "registry:component"+ }+ ],+ "dependencies": ["@supabase/supabase-js@latest"]+}diff --git a/blocks/vue/registry/index.ts b/blocks/vue/registry/index.tsindex 234d41068b0..b432fb397b9 100644--- a/blocks/vue/registry/index.ts+++ b/blocks/vue/registry/index.ts@@ -1,5 +1,6 @@import { clients } from './clients'+import { passwordBasedAuth } from './password-based-auth'-const blocks = [...clients]+const blocks = [...clients, ...passwordBasedAuth]export { blocks }diff --git a/blocks/vue/registry/password-based-auth.ts b/blocks/vue/registry/password-based-auth.tsnew file mode 100644index 00000000000..065b2843fd0--- /dev/null+++ b/blocks/vue/registry/password-based-auth.ts@@ -0,0 +1,5 @@+import { type Registry } from 'shadcn/schema'+import nuxtjs from './default/password-based-auth/nuxtjs/registry-item.json' with { type: 'json' }+import vue from './default/password-based-auth/vue/registry-item.json' with { type: 'json' }++export const passwordBasedAuth = [nuxtjs, vue] as Registry['items']diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 7d151f3d8e1..3be2477b455 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -400,13 +400,13 @@ importers:version: 1.0.3(@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])'@sentry/nextjs':specifier: ^10.3.0- version: 10.3.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])+ version: 10.3.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@babel/[email protected]([email protected]))(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])'@supabase/supabase-js':specifier: 'catalog:'version: 2.78.0'@tailwindcss/container-queries':specifier: ^0.1.1- version: 0.1.1([email protected])'@tanstack/react-query':specifier: ^5.13.4version: 5.13.4([email protected])@@ -705,6 +705,9 @@ importers:smol-toml:specifier: ^1.3.1version: 1.3.1+ tailwindcss:+ specifier: 'catalog:'tsconfig:specifier: workspace:*version: link:../../packages/tsconfig@@ -815,7 +818,7 @@ importers:version: 1.1.3(@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])'@sentry/nextjs':specifier: ^10.3.0- version: 10.3.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])+ version: 10.3.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@babel/[email protected]([email protected]))(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])'@std/path':specifier: npm:@jsr/std__path@^1.0.8version: '@jsr/[email protected]'@@ -1576,7 +1579,7 @@ importers:version: 1.0.5(@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])'@sentry/nextjs':specifier: ^10- version: 10.3.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])+ version: 10.3.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@babel/[email protected]([email protected]))(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])'@supabase/supabase-js':specifier: 'catalog:'version: 2.78.0@@ -1812,12 +1815,27 @@ importers:'@supabase/supabase-js':specifier: 'catalog:'version: 2.78.0+ class-variance-authority:+ specifier: ^0.7.1+ version: 0.7.1+ clsx:+ specifier: ^2.1.1+ version: 2.1.1h3:specifier: ^1.15.4version: 1.15.4nuxt:specifier: ^4.0.3version: 4.1.2(@electric-sql/[email protected])(@parcel/[email protected])(@types/[email protected])(@vue/[email protected])([email protected])([email protected](@electric-sql/[email protected])([email protected](@electric-sql/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])))([email protected](@electric-sql/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected]))([email protected])([email protected]([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])+ tailwind-merge:+ specifier: ^3.3.1+ version: 3.3.1+ vue:+ specifier: ^3.5.21+ version: 3.5.21([email protected])+ vue-router:+ specifier: ^4.5.1+ version: 4.5.1([email protected]([email protected]))devDependencies:shadcn:specifier: ^3.0.0@@ -18319,9 +18337,6 @@ packages:engines: {node: '>=14.0.0'}hasBin: true- resolution: {integrity: sha512-i+zidfmTqtwquj4hMEwdjshYYgMbOrPzb9a0M3ZgNa0JMoZeFC6bxZvO8yr8ozS6ix2SDz0+mvryPeBs2TFE+w==}-resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==}engines: {node: '>=6'}@@ -27566,7 +27581,7 @@ snapshots:'@sentry/[email protected]': {}- '@sentry/[email protected](@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])':+ '@sentry/[email protected](@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@babel/[email protected]([email protected]))(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])':dependencies:'@opentelemetry/api': 1.9.0'@opentelemetry/semantic-conventions': 1.36.0@@ -28535,10 +28550,6 @@ snapshots:dependencies:- '@tailwindcss/[email protected]([email protected])':- dependencies:- tailwindcss: 4.1.13-'@tailwindcss/[email protected]([email protected]([email protected](@types/[email protected])([email protected])))':dependencies:mini-svg-data-uri: 1.4.4@@ -40642,8 +40653,6 @@ snapshots:transitivePeerDependencies:- ts-node- [email protected]: {}-