Amara
01/13/2023, 11:59 AMDbugger
01/13/2023, 12:51 PMimport { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers':
'authorization, x-client-info, apikey, content-type',
};
serve(async (req) => {
// It doesnt work... WHY?
// const data = await req.json().body;
// It works... WHY?
const data = { message: `Hello world!` };
return new Response(JSON.stringify(data), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
});
});
For some reason, if I try to use await req.json()
as the data, I get a CORS error, whereas if I send an static object it works...
Why could this be?Zerkia
01/13/2023, 4:31 PMconst [email, setEmail] = useState('');
const [password, setpassword] = useState('');
const [password2, setPassword2] = useState('');
const [fullname, setFullname] = useState('');
const [phonenumber, setPhonenumber] = useState(0);
const [birthday, setBirthday] = useState('');
const [Rmsg, setRmsg] = useState('');
const [user, setUser] = useState('');
const Register = async () => {
const {data} = await supabase.auth.signUp({
email,
password,
},
{
data:
fullname,
phonenumber,
birthday
})
if (password != password2){
setRmsg('Passwords do not match')
} else {
setRmsg('User Created Successfully')
console.log(data.user)
setUser(user)
}
}
The basic idea is that I want to be able to register a user, and push their email, password, full name, phone number and birthday into my database, so I can display specific wanted details on a profile page later on.
However, when trying to do this, it asks for just 1 argument, and not 2, but when doing so, it seemingly does not allow anything but email and password?
A little disclaimer: I've only started programming in React, Ionic and Supabase a week ago, so everything is still new to me (Especially Supabase), so sorry in advance if my explanation is not that good.Dbugger
01/13/2023, 4:38 PMsupabase.functions.invoke(...)
, a request is made, with the header authorisation: Bearer xxxxxx
.
Is it possible to get that token manually, thought the supabase client? Something like supabase.auth.access_token()
, or something similar?B3n
01/13/2023, 4:49 PManggoran
01/13/2023, 5:13 PMsql
DO $$
DECLARE
s TEXT;
schemata TEXT[] := ARRAY['test', 'public'];
BEGIN
FOREACH s IN ARRAY schemata LOOP
CREATE TABLE IF NOT EXISTS s.members (
id UUID DEFAULT uuid_generate_v4(),
PRIMARY KEY ( id )
);
ALTER TABLE s.members
ENABLE ROW LEVEL SECURITY,
ADD COLUMN IF NOT EXISTS supporter_id UUID REFERENCES s.members ( id ),
ADD COLUMN IF NOT EXISTS email VARCHAR NOT NULL,
ADD COLUMN IF NOT EXISTS name TEXT NOT NULL,
ADD COLUMN IF NOT EXISTS role VARCHAR NOT NULL,
ADD COLUMN IF NOT EXISTS super_admin BOOLEAN NOT NULL DEFAULT false;
DROP POLICY IF EXISTS "Enable READ for authenticated users." ON s.members;
CREATE POLICY "Enable READ for authenticated users." ON s.members
AS PERMISSIVE FOR SELECT
TO authenticated
USING ( true );
DROP POLICY IF EXISTS "Enable UPDATE for super admins." ON s.members;
CREATE POLICY "Enable UPDATE for super admins in" ON s.members
AS PERMISSIVE FOR UPDATE
TO authenticated
USING ( is_admin() = true )
WITH CHECK ( is_admin() = true );
END LOOP;
END;
$$;
But it returns Failed to run sql query: schema "s" does not exist
Cake Daddy
01/13/2023, 5:50 PMDbugger
01/13/2023, 5:50 PMjs
const handler = (req, res) => {
const { authorization } = req.headers;
const supabaseUrl = 'https://xxxxxxxx.supabase.co';
// const anonKey = 'yyyyyyyyyy';
const serviceKey = 'zzzzzzzzzzz';
const options = { global: { headers: { Authorization: authorization } } };
const supabase = createClient(supabaseUrl, serviceKey, options);
supabase
.from('prompts')
.insert([{ title: 'test', body: 'test' }])
.then((data) => {
console.log(data);
res.status(200).json({ name: data });
});
};
But this way, the RLS Policies are still being applied. Could it be because I am using the bearer token that was given to me by the client, while using the anon key? If so, how should I do it then?enyo
01/13/2023, 6:11 PMjh
01/13/2023, 6:23 PMname: Deploy Function
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
PROJECT_ID: zdtdtxajzydjqzuktnqx
steps:
- uses: actions/checkout@v3
- uses: supabase/setup-cli@v1
with:
version: 1.0.0
- run: supabase functions deploy github-action-deploy --project-ref $PROJECT_ID
When it attempts to deploy I see the following:
Run supabase functions deploy hello --project-ref $PROJECT_ID
You can generate an access token from https://app.supabase.com/account/tokens.
Enter your access token: Cancelled supabase login.
Bundling hello
Error: Access token not provided. Supply an access token by running supabase login or setting the SUPABASE_ACCESS_TOKEN environment variable.
Error: Process completed with exit code 1.
Any advice on how I should supply the SUPABASE_ACCESS_TOKEN and keep it out of the github repo?
ThanksAadarsh805
01/13/2023, 6:42 PMMax52
01/13/2023, 9:20 PM$page.data.session
populating properly. However I get the AuthSessionMissingError
error when trying to reset a password using the code here:
js
const { data, error } = await supabaseClient.auth.updateUser({
password: password,
});
and it also seems that the user is returning null from this code:
js
const { data: user } = await supabaseClient.auth.getUser();
petoma
01/13/2023, 9:36 PMqueryFn: async (args) => {
const { limit, level, musicStyle } = args;
const {data, count, error} = await supabase
.from('all_preloads')
.select('*', {count: "exact", head: true})
.eq('level', level)
.contains('musicStyle', musicStyle)
.order('created_at', { ascending: false })
.limit(limit)
console.log(count)
return { data, error }
},
The parameter "level" has to match exactly with the column level, however a song can have several musicStyles, so I have done that field an array, and I would like to be filtered once the parameter !== "" and the value is included in the array.
I hope I have explained it properly. Thanks!Cake Daddy
01/13/2023, 10:08 PMstibbs
01/13/2023, 10:23 PMpatrick
01/13/2023, 10:46 PM{{ .Token }}
in the email template – is there a method in the JS SDK that allows the user to submit this?pkdiscgolf
01/14/2023, 12:04 AMEthanxyz
01/14/2023, 12:14 AMAgents
to manage their Clients
data
- The App will be marketed as a FREE to use application ( no mostly cost like a traditional SaaS ), but would require you to work for our company @ExampleCompany.com
.
- Thus, the app should require a @ExampleCompany.com
( Our Company ) email to login / sign up as an Agent
Whitelisted Login Options I have looked into...
1. Anyone can sign up, manual RLS updates - Allow anyone to sign up, but prevent all read/writes with RLS by default, displaying a waiting for verification
page in the App, and having a System Admin manually verify users as Agents
.
2. Disable signup by default, System Admin sends signup links to clients directly - Seems like there could be issues / bugs with this ( e.g. https://github.com/supabase/supabase/discussions/4296 ) but could be an option.
3. Function + Trigger - Here is a good example, https://github.com/supabase/supabase/issues/6228#issuecomment-1095235706, but I am not sure if this is good practice. This does seem like the best option for automation however ; and might be able to be expanded to offer @SomePartnerCompany.com
emails.
Does anyone have any tips for how I should go about this given my App Background ?DYELbrah
01/14/2023, 3:01 AMconst { data: publicData, error: publicError } = await supabase.from('customer').select(columns).eq('id', viewableObjectId).single();
When I hover over the type for publicData, I see the types:
const publicData: GenericStringError | null
I found this thread which mentions simply adding as any to the variable inside .select() however, I'm still receiving the same GenericStringError.
const { data: publicData, error: publicError } = await supabase.from(tableName).select(columns as any).eq('id', viewableObjectId).single();
This still returns the same Error type.
Is this a known bug? I see the ticket was closed but the proposed workaround isn't working sadly. I am getting the correct data back, it's just the types being returned that are wrong.
Thanks in advance!Norm
01/14/2023, 3:04 AMlet results:Database['public']['Tables']['results']['Row'][] = [];
This seems awfully wordy. Is this the "right way" to properly define my results object?yayza_
01/14/2023, 7:58 AMjs
// handle is a hook that runs every time the server receives a request.
export const handle = async ({ event, resolve }) => {
const { session, supabaseClient } = await getSupabase(event);
event.locals.sb = supabaseClient;
event.locals.session = session;
const user = await supabaseClient.auth.getUser(session?.access_token);
console.log(user)
return resolve(event);
};
It still logs all the user details even though it's not in the database anymore.. am I wrong to assume that's what it's for or am I suppose to query the auth table myself to check if the user exists still (if that's possible)? 🤔mikeladion
01/14/2023, 11:42 AMKarmotrine
01/14/2023, 12:11 PMHugos
01/14/2023, 12:46 PMcorey
01/14/2023, 1:38 PMAntDX316
01/14/2023, 1:49 PMSeñor Bruno
01/14/2023, 2:19 PMmotorhead
01/14/2023, 4:14 PMgoldyman
01/14/2023, 3:54 PMAlexander
01/14/2023, 4:33 PM@GET
@Path("users/{id}/foods")
@RolesAllowed({ "User", "Admin" })
List<Food> getFoods(){
...
}