diff --git a/docs/examples/users.md b/docs/examples/users.md index ed2613d2b..6ce38abbb 100644 --- a/docs/examples/users.md +++ b/docs/examples/users.md @@ -456,15 +456,16 @@ Here's a function to get the email of the currently authenticated user. ```sql +-- Prevent current_setting('postgrest.claims.email') from raising +-- an exception if the setting is not present. Default it to ''. +ALTER DATABASE your_db_name SET postgrest.claims.email TO ''; + create or replace function basic_auth.current_email() returns text language plpgsql as $$ begin return current_setting('postgrest.claims.email'); -exception - -- handle unrecognized configuration parameter error - when undefined_object then return ''; end; $$; ```