- You've successfully signed up. Please check your email to
- confirm your account before signing in.
+ Your account is ready. You can sign in and start using Habit Pet.
diff --git a/components/sign-up-form.tsx b/components/sign-up-form.tsx
index 6c4b369..3ee7a52 100644
--- a/components/sign-up-form.tsx
+++ b/components/sign-up-form.tsx
@@ -40,14 +40,18 @@ export function SignUpForm({
}
try {
- const { error } = await supabase.auth.signUp({
+ const { data, error } = await supabase.auth.signUp({
email,
password,
options: {
- emailRedirectTo: `${window.location.origin}/protected`,
+ emailRedirectTo: `${window.location.origin}/auth/confirm?next=/protected`,
},
});
if (error) throw error;
+ if (data.session) {
+ router.push("/protected");
+ return;
+ }
router.push("/auth/sign-up-success");
} catch (error: unknown) {
setError(error instanceof Error ? error.message : "An error occurred");
diff --git a/supabase/config.toml b/supabase/config.toml
index 12ccd61..7c872ee 100644
--- a/supabase/config.toml
+++ b/supabase/config.toml
@@ -30,8 +30,14 @@ file_size_limit = "50MiB"
[auth]
enabled = true
-site_url = "http://127.0.0.1:3000"
-additional_redirect_urls = ["http://127.0.0.1:3000/**", "http://localhost:3000/**"]
+site_url = "https://cursor-hackathon-flame.vercel.app"
+additional_redirect_urls = [
+ "http://127.0.0.1:3000/**",
+ "http://localhost:3000/**",
+ "https://cursor-hackathon-flame.vercel.app/**",
+ "https://cursor-hackathon-*-harkamal-randhawas-projects.vercel.app/**",
+ "https://cursor-hackathon-*-recentrunner-harkamal-randhawas-projects.vercel.app/**",
+]
jwt_expiry = 3600
enable_refresh_token_rotation = true
refresh_token_reuse_interval = 10
diff --git a/supabase/migrations/20260524010000_create_profile_on_signup.sql b/supabase/migrations/20260524010000_create_profile_on_signup.sql
new file mode 100644
index 0000000..c83cd66
--- /dev/null
+++ b/supabase/migrations/20260524010000_create_profile_on_signup.sql
@@ -0,0 +1,28 @@
+create or replace function public.handle_new_user()
+returns trigger
+language plpgsql
+security definer
+set search_path = public
+as $$
+begin
+ insert into public.profiles (id, display_name)
+ values (
+ new.id,
+ coalesce(new.raw_user_meta_data ->> 'display_name', split_part(new.email, '@', 1))
+ )
+ on conflict (id) do nothing;
+
+ insert into public.avatar_state (user_id)
+ values (new.id)
+ on conflict (user_id) do nothing;
+
+ return new;
+end;
+$$;
+
+drop trigger if exists on_auth_user_created on auth.users;
+
+create trigger on_auth_user_created
+ after insert on auth.users
+ for each row
+ execute function public.handle_new_user();