mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-10-31 18:19:43 +00:00
fix(redemption): restore profile email on signup
This commit is contained in:
1 parent
bf2ef59688
commit
79862dac13
2 files changed
+36
-1
No files matched your search
@@ -0,0 +1,35 @@
|
|||||||
|
-- A production schema sync replaced the signup trigger function without
|
||||||
|
-- copying auth.users.email. Redemption by email and admin user lookup both
|
||||||
|
-- depend on profiles.email being populated.
|
||||||
|
CREATE OR REPLACE FUNCTION public.handle_new_user()
|
||||||
|
RETURNS trigger
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
SECURITY DEFINER
|
||||||
|
SET search_path TO ''
|
||||||
|
AS $function$
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO public.profiles (
|
||||||
|
id,
|
||||||
|
email,
|
||||||
|
created_at,
|
||||||
|
updated_at,
|
||||||
|
onboarding_completed
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
NEW.id,
|
||||||
|
NEW.email,
|
||||||
|
NOW(),
|
||||||
|
NOW(),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$function$;
|
||||||
|
|
||||||
|
UPDATE public.profiles AS profile
|
||||||
|
SET email = auth_user.email,
|
||||||
|
updated_at = NOW()
|
||||||
|
FROM auth.users AS auth_user
|
||||||
|
WHERE profile.id = auth_user.id
|
||||||
|
AND profile.email IS NULL
|
||||||
|
AND auth_user.email IS NOT NULL;
|
||||||
@@ -34,7 +34,7 @@ Deno.test("redeem-code: successfully redeems code for user", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
assertEquals(res.status, 200);
|
assertEquals(res.status, 200, JSON.stringify(data));
|
||||||
assertEquals(data.success, true);
|
assertEquals(data.success, true);
|
||||||
|
|
||||||
// 4. Verify Profile is Premium
|
// 4. Verify Profile is Premium
|
||||||
|
|||||||
Reference in new issue
Block a user