brassotron
11/02/2022, 12:59 AMsql
create table public.profile (
profile_id uuid references auth.users not null primary key,
first_name text,
last_name text,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone
);
alter table public.profile
enable row level security;
create policy "Users can select their own profile." on public.profile
for select using (auth.uid() = profile_id);
create policy "Users can insert their own profile." on public.profile
for insert with check (auth.uid() = profile_id);
create policy "Users can update own profile." on public.profile
for update using (auth.uid() = profile_id);
create function public.handle_new_user()
returns trigger as $$
begin
insert into public.profile (profile_id, first_name, last_name)
values (new.id, new.raw_user_meta_data->>'first_name', new.raw_user_meta_data->>'last_name');
return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
But if I then try to invite a user via the Supabase dashboard, I get this error:
Failed to invite user: Database error finding user
However, in the above if I change:
sql
create policy "Users can select their own profile." on public.profile
for select using (auth.uid() = profile_id);
to
sql
create policy "Users can select their own profile." on public.profile
for select using (true);
It allows me to invite users without error?
Thanks for any help!PhilipWee
11/02/2022, 1:29 AMWalrusking
11/02/2022, 2:28 AMBlobby
11/02/2022, 2:36 AMProperty 'on' does not exist on type 'PostgrestQueryBuilder<any, any>'.ts(2339)
javascript
import { useSessionContext } from '@supabase/auth-helpers-react';
const Component() => {
const { session, supabaseClient } = useSessionContext();
useEffect(() => {
const subs = supabaseClient
.from("objects")
.on("UPDATE", (payload) => {
// dispatch(updateGameObject(payload.new.data));
})
.subscribe(console.log);
subs.onClose(() => {
console.log("on closed");
supabase.removeAllSubscriptions();
});
return () => {
subs.unsubscribe();
};
}
alanpham
11/02/2022, 3:55 AMDesmond
11/02/2022, 8:48 AMBamsespartymix
11/02/2022, 9:11 AMcreate or replace function get_dates(user_id_input uuid, friend_id_input uuid) returns setof record language sql as $$
SELECT date, COUNT(date)
FROM available_dates
where user_id = (user_id_input)
or user_id = (friend_id_input)
GROUP BY date
HAVING COUNT(date) > 1;
$$;
STILLWATER;
11/02/2022, 10:22 AMoliver-kriska
11/02/2022, 12:50 PMprepared statement "ecto_5765" does not exist
and similar. Any idea what can be wrong?tpz
11/02/2022, 2:05 PMThoth Trismegistus
11/02/2022, 2:13 PMEmbm
11/02/2022, 2:59 PMtable_a
with a select
rls open to everyone, but on an editor page of my app I want to check if the user actually fulfills the necessary update
rls (that is more constraining) before fetching the data. I can see many ways of doing this:
- moving the update
rls logic into a procedure that I can then separately call from my app's server to check before doing a select
- manually keeping my app's select
query's filter up to date with the update
rls
- ?? doing an empty update
with a select
modifier
Is the last one a bad practice? Is there some other way of asking pg/sql to use the update
rls for a specific select
query without having to replicate the policie's logic?sosapps
11/02/2022, 5:00 PMCheqo
11/02/2022, 5:14 PMconfirm email
switch, when toggled users will have to verify their emails, if they don't they can't sign in.
I want to delay the authentication to 24 or 48hours, I know that it's currently not possible, how something like this can be implemented?
Should I make feature request?Jordan92
11/02/2022, 6:46 PMdev Joakim Pedersen
11/02/2022, 7:06 PMpakkerr
11/02/2022, 7:22 PMconst sendVerificationCode = async (data) => {
setLoading(true)
setEmail(data.email)
const { error } = await supabase.auth.signInWithOtp({
email,
shouldCreateUser: false
})
if (!error) {
setLoading(false)
router.push('/sign-up/with-email/verify-email')
} else {
setLoading(false)
console.log(error)
}
}
The email with the verification code gets sent successfully, but I notice that a verified user is created in supabase, before verifying the OTP. This is problem 1 and I am not sure what's going wrong.
The second problem is a 401 error is returned when calling the verifyOtp function on the subsequent page.
The code for this function is here:
const [email] = useEmailSignUpStore((state) => [state.email], shallow);
const verifyCode = async (formData) => {
setErrorMSG(null)
setLoading(true)
const token = formData.otpInput
const { error } = await supabase.auth.verifyOtp({ email, token, type: 'signup' })
if (!error) {
setLoading(false)
router.push('/sign-up/with-email/complete-profile')
} else {
setLoading(false)
console.log(error)
setErrorMSG('Invalid Verification Code')
}
}
jkjr
11/02/2022, 7:27 PMlewisd
11/02/2022, 8:14 PMcode:500
error_id:"17246b26-b51a-4408-b5d6-fb2a0ee891be"
msg:"Internal server error"
This is calling https://pqxrgqvvtvjseejnwqvh.supabase.co/auth/v1/user
Looking at the auth logs, the error says:
"msg": "Unhandled server error: invalid claim: subject missing",
Anyone ran into these problems before?
I have `console.log`'d my supabase url and key and can confirm both are there, in the enviroment variables hosted on vercel.reed
11/02/2022, 8:27 PMsignup
method, and once to verify the otp via verifyOtp
method)?noahflk
11/02/2022, 10:34 PMonSuccess
callback on the supabaseClient.auth.signInWithOAuth
function.KTibow
11/02/2022, 11:00 PMcaseycrogers
11/02/2022, 11:16 PMPostGrestFilterBuidler
object so I can get a second instance of it?
I have a long function that slowly builds up a PostGrestFilterBuilder
with a series of filters.
Then, at the end, I want to run the query twice, once with one filter, and once with another, and return both results (I can't use an and
because I'm using this to affect the ordering). I'm basically doing a convoluted order by some_column = some_value
. I have to do it this way because AFAIK the supabase orderBy
function only supports strict column names, not espressions
Here's a shortened example of what I want:
dart
Stream<Foo> getFoos(PostGrestFilterBuilder builder) async* {
var builderA = builder.copy().eq('some_col', 'some_value');
yield* _paginated(builderA);
var builderB = builder.copy().neq('some_col', 'some_value');
yield* _paginated(builderB);
}
Alternatively, you guys could make the filter methods return a new object instead of mutating the existing one. Side effects suck, they're hard to reason about and work with. They're especially obnoxious here because the following (extremely common pattern) makes the linter yell at you for not awaiting a future:
dart
if (limit != null) {
builder.limit(limit);
}
The following is much more explicit and doesn't make the linter mad:
dart
if (limit != null) {
// If limit returned a new instance instead of side effecting:
builder = builder.limit(limit);
}
Hege
11/02/2022, 11:26 PMJustinT
11/02/2022, 11:49 PMBlobby
11/02/2022, 11:52 PMError: The "host" request header is not available
at isSecureEnvironment (D:\code\gameface\node_modules\@supabase\auth-helpers-shared\dist\index.js:226:11)
at Object.setItem (D:\code\gameface\node_modules\@supabase\auth-helpers-shared\dist\index.js:402:47)
at D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\lib\helpers.js:89:19
at Generator.next (<anonymous>)
at D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\lib\helpers.js:31:71
at new Promise (<anonymous>)
at __awaiter (D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\lib\helpers.js:27:12)
at setItemAsync (D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\lib\helpers.js:88:46)
at SupabaseAuthClient._persistSession (D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\GoTrueClient.js:840:43)
at SupabaseAuthClient.<anonymous> (D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\GoTrueClient.js:835:28)
Help?Dotjosh
11/03/2022, 12:56 AM((()))
11/03/2022, 1:16 AMDies.Irae
11/03/2022, 3:24 AMwhiskeywizard
11/03/2022, 4:33 AM