-- 006_review_account.sql - one account the app stores' reviewers can sign in to (2026-10-18). -- -- Google Play and Apple review need a sign-in that always works: reviewers can't receive an -- email code, and may not use their own Google or Apple account. So one account, flagged by the -- owner, may sign in with a password. Every other account stays code-only (004). -- -- The flag is app_metadata.review_account = true. Only the service role (Supabase dashboard, -- or the admin API) can set app_metadata; a person signed in, or a connected app, can't. Set it: -- update auth.users set raw_app_meta_data = raw_app_meta_data || '{"review_account": true}' -- where email = ''; -- That account holds demo notes only. Change or remove its password when a review is done. -- -- Safe on a live database: replaces the hook from 004 and schema_version(). Nothing moves. -- -- ROLLBACK: run 004's create function again (every password refused), schema_version() back to 5. create or replace function public.mullo_access_token_hook(event jsonb) returns jsonb language plpgsql stable set search_path = '' as $$ begin if (event ->> 'authentication_method' = 'password' or coalesce(event -> 'claims' -> 'amr', '[]'::jsonb) @> '[{"method": "password"}]'::jsonb) and coalesce(event -> 'claims' -> 'app_metadata' ->> 'review_account', '') <> 'true' then return jsonb_build_object('error', jsonb_build_object( 'http_code', 403, 'message', 'Mullo signs in with an email code, not a password.')); end if; return event; end $$; revoke all on function public.mullo_access_token_hook(jsonb) from public, anon, authenticated; grant execute on function public.mullo_access_token_hook(jsonb) to supabase_auth_admin; create or replace function public.schema_version() returns int language sql immutable set search_path = '' as $$ select 6 $$; -- After applying: verify, don't assume. -- select public.schema_version(); -- expect 6 -- select public.mullo_access_token_hook('{"authentication_method":"password","claims":{}}'); -- -- expect {"error": {"http_code": 403, ...}} -- select public.mullo_access_token_hook('{"authentication_method":"password","claims":{"app_metadata":{"review_account":true}}}'); -- -- expect the event back unchanged