dev Joakim Pedersen
01/18/2023, 3:34 PMdandis
01/18/2023, 4:18 PMexport const getQuotas = async (company_id) => {
let { data: quota, error } = await supabase.from('quota').select('*');
const quotaData = quota;
return quotaData;
};
When I log what this function returns, it's simply an empty array. I have the said table (quota) populated.Esore
01/18/2023, 5:11 PMCREATE OR REPLACE FUNCTION create_user_and_account()
RETURNS TRIGGER AS $$
DECLARE new_id UUID;
BEGIN
SELECT gen_random_uuid() INTO new_id;
INSERT INTO public.users(id, email) VALUES (new_id, NEW.email);
INSERT INTO public.accounts(owner_id) VALUES (new_id);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER create_user_and_account_trigger
AFTER INSERT ON auth.users
FOR EACH ROW
EXECUTE FUNCTION create_user_and_account();
I get success, however now when I try to register a new user it is unable to. Why is this the case and how can i remedy it? What I am trying to do is since we cannot edit the auth.users table I want to be able to get the information from it such as the id and email and put into a newly built public.auth table and put that data inthere and also create a public.account row so that it is a user inside an account. The reason that I did this is that I want multiple users to be within 1 account like for an Enterprise System. Any help would be great!JeromeK
01/18/2023, 5:46 PM/pages/login.tsx
ts
const { error, data } = await supabase.auth.signInWithPassword({email, password});
/lib/supabaseClient.ts
ts
import { createClient } from "@supabase/supabase-js";
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
export const supabase = createClient(supabaseUrl, supabaseKey);
and I would like to validate it like this on /middleware.ts
ts
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { createMiddlewareSupabaseClient } from "@supabase/auth-helpers-nextjs";
export async function middleware(req: NextRequest) {
const res = NextResponse.next();
// Create authenticated Supabase Client.
const supabase = createMiddlewareSupabaseClient({ req, res });
const {data: { session }} = await supabase.auth.getSession(); // this returns always null
if (req.nextUrl.pathname.startsWith("/dashboard")) {
console.log(session);
}
}
Kottalo Laurant
01/18/2023, 6:02 PMlogemann
01/18/2023, 6:06 PMyekta
01/18/2023, 6:24 PMDbugger
01/18/2023, 6:55 PMadminclient.from('prompts').select().eq('id', id).single();
And this the answer
{
"code": "22P02",
"details": null,
"hint": null,
"message": "invalid input syntax for type bigint: \"9021b0c0-c1d7-4c45-9772-fdfe05b2f90e\""
}
The weirdest part is that it works on my local dev, but when deployed, it gives me the error, even though the base is clearly an "uuid"garyaustin
01/18/2023, 7:18 PMDbugger
01/18/2023, 7:50 PMSmardrengr
01/18/2023, 9:11 PMgames.players_conf
when someone, anyone, joins a game
. However, while I want only the game organizer to be able to update other details in the game record that he created, unless I allow all to update that column, the function is not allowed to run.
Question: Can I write a policy that allows something like:
create policy "Organizers can update their own games."
on games for update
using ( auth.uid() = organizer_id );
CREATE POLICY games_players_update
ON games
FOR UPDATE
TO public
WITH CHECK (cols = '{players_conf}')
56e5
01/18/2023, 9:15 PMconst user = useUser();
useEffect(() => {
if (!user) {
// Redirect somewhere relevant
}
}, [user]);
will always redirect on page load, because user
seems to start out falsy while it's doing some checks and populating the value, even if the user turns out to be actually logged in in the end.
I want to do something like:
const user = useUser();
useEffect(() => {
if (user.isReady && !user) {
// Redirect somewhere relevant
}
}, [user]);
Does this exist? Maybe I can use session
like this somehow?
Thanks!cayblood
01/18/2023, 10:36 PMsupabase start
command still takes about 2m30s to run. It would be great to be able to speed up a deployment by using a remote supabase database that gets reset with each new deployment. Is there a way to tell supabase db test
to run against a remote database?Deng
01/18/2023, 11:29 PMnakulthebuilder
01/18/2023, 11:47 PMsupabaseClient.auth.signUp({email, password})
I am getting a 500 error url argument is missing
. I am guessing this is related to the SITE_URL
, which is currently set to a subdomain I am using for development, however I've tried a number of different ways and updated the redirect urls with wildcards and nothing seems to work. I have also tried restarting the Supabase server to no avail. Any guidance would be very much appreciated. Note: It's working fine when using my local supabase db.logemann
01/19/2023, 12:45 AMale.k
01/19/2023, 1:22 AMBlobby
01/19/2023, 2:37 AMbob_the_robot
01/19/2023, 3:21 AMError adding policy: failed to create pg.policies: syntax error at or near ";"
sql
CREATE POLICY "game creator can view invites" ON "public"."game_invites"
AS PERMISSIVE FOR SELECT
TO authenticated
USING (( 1 <= ( SELECT COUNT(*) FROM game_invites WHERE game_id = ( SELECT current_game FROM profiles WHERE id = uid() ) ))
I tried also select exists()
but that gives me error Error adding policy: failed to create pg.policies: syntax error at or near "SELECT"
sql
SELECT EXISTS (
SELECT
COUNT(*)
FROM
game_invites
WHERE
game_id = (
SELECT
current_game
FROM
profiles
WHERE
id = uid()
)
)
VuNguyen
01/19/2023, 3:53 AMdrewbie
01/19/2023, 4:05 AMShelby
01/19/2023, 4:48 AMjs
const { data, error } = await supabaseClient.auth.signInWithOAuth({
provider: 'twitter',
options : {
data : {
credits: 1,
used_credits: 0
}
}
})
CherterB
01/19/2023, 8:48 AMflapili (FR, bad EN)
01/19/2023, 8:56 AMAissam
01/19/2023, 9:09 AMboeledi
01/19/2023, 9:10 AMlyu
01/19/2023, 9:13 AMonConflict
parameter in upsert
function of supabase js library?
This is my code and it doesn't work
await supabase.from('users')
.upsert(
{ id: 4, name: "Lorem ipsum" },
{onConflict: 'id'}
);
eggnog.
01/19/2023, 9:17 AMkabaday
01/19/2023, 10:03 AMjavascript
const { data: folders, error: err } = await locals.sb
.from('folder')
.select('*, children:note(*).folder(*)')
.eq('owner', owner)
.is('parent_folderId', null)
.order('created_at', { ascending: true })
With this i get all the child notes inside children, but not the folders. How can i also store all child folders inside children?
The best case would be to also get all sub notes and folder recursively to get a folder structure like object:
|- Folder 1
| |- note
| |- childFolder
| | |- note
| | |- ...
|- Folder 2
|...
ccssmnn
01/19/2023, 10:38 AMsupabase.auth.updateUser({ email: data.email })
to set a new email address for the user (email sign in). After confirming the change by pressing the link received via mail, the user still has the old email address.
This problem occurs during development and in production. I must be missing something.