nahtnam
01/31/2023, 7:58 AMμ΅μ§μ°
01/31/2023, 9:10 AMimport { supabase } from '@lib/supabase/supabase';
import { FormEvent, useState } from 'react';
export default function Page() {
const [datas, setDatas] = useState({
email: '',
password: '',
athletic_experience: '',
});
async function handleSubmits(e: FormEvent) {
e.preventDefault();
try {
const { data, error } = await supabase.auth.signUp({
email: datas.email,
password: datas.password,
options: {
data: {
athletic_experience: datas.athletic_experience,
},
},
});
} catch (error) {
console.log(error);
}
}
console.log(datas);
function onchange(event: { target: { name: string; value: string } }) {
setDatas((prev) => {
return {
...prev,
[event.target.name]: event.target.value,
};
});
}
return (
<form onSubmit={handleSubmits}>
<input
onChange={onchange}
placeholder="μ
λ ₯νμΈμ"
name="email"
type="text"
/>
<input
onChange={onchange}
placeholder="μ
λ ₯νμΈμ"
name="password"
type="text"
/>
<input
onChange={onchange}
placeholder="μ
λ ₯νμΈμ"
name="athletic_experience"
type="text"
/>
<button type="submit">μ μ‘</button>
</form>
);
}
Solid Snake
01/31/2023, 12:37 PMlet { data, error } = await supabase.from('profiles').select('
*,
users1 (
*
),
users2 (
*
)
').eq('id', session.user.id)
.limit(1)
.single()
ThanksHugos
01/31/2023, 1:14 PMlake_mattiato
01/31/2023, 2:11 PMsalzar
01/31/2023, 2:18 PMHugos
01/31/2023, 2:22 PMAnarki
01/31/2023, 2:27 PMImposer
01/31/2023, 3:02 PMRomi
01/31/2023, 3:46 PMrahul3v
01/31/2023, 4:19 PMGuus Iwanow
01/31/2023, 4:24 PMRomi
01/31/2023, 5:26 PMsnowgears
01/31/2023, 5:43 PMjs
// Create a Supabase client with the Auth context of the logged in user.
const supabaseClient = createClient(
// Supabase API URL - env var exported by default.
Deno.env.get('SUPABASE_URL') ?? '',
// Supabase API ANON KEY - env var exported by default.
Deno.env.get('SUPABASE_ANON_KEY') ?? '',
// Create client with Auth context of the user that called the function.
// This way your row-level-security (RLS) policies are applied.
{ global: { headers: { Authorization: req.headers.get('Authorization')! } } }
)
// Now we can get the session or user object
const {
data: { user },
} = await supabaseClient.auth.getUser()
const { error } = await supabaseClient
.from('resource_purchase')
.insert({ server_id : 868241175688151051, resource_id: 9628, price: 0.00, email: 'tanner_test@gmail.com' })
if (error) throw error
But it says relation public.resource_purchase does not exist. But it does exist. Am I missing something here?
{
"error": "relation \"public.resource_purchase\" does not exist"
}
Lois
01/31/2023, 5:50 PMraise mapped_exc(message) from exc
httpx.ReadTimeout: The read operation timed out
I am using this in python:
response = supabase.table("db").select("name").range(2000000,2999999).execute()
Is there any way I can work around with this? I saw the documentation mention about alter role
but not sure what next.
Also the maximum read is 1000000 rows, is there way to increase this?Martin Piliar
01/31/2023, 6:17 PMSQL
create or replace function public.handle_new_category()
returns trigger as $$
begin
insert into public.category_types (category_id,is_official)
values (new.id, organization_can_publish(get_user_organization(???USERID???)));
return new;
end;
$$ language plpgsql security definer;
As you can see, I have a function that returns true or false depending on the fact if the organization has publishing access - and I have to get the organization with the user_id, but I'm not sure how to get the user ID as I'm not working with the users/profiles table (the ???USERID??? is the point I need help with)shantanubharadwaj
01/31/2023, 7:26 PMmaglev
01/31/2023, 8:59 PMsnowgears
01/31/2023, 11:02 PMjs
const { error } = await supabase
.from('resource_purchase')
.insert({ server_id : 868241175688151051, resource_id: 9628, price: 0.00, email: 'tanner_test@gmail.com' })
if (error) throw error
throws an error
{
"error": "insert or update on table \"resource_purchase\" violates foreign key constraint \"resource_purchase_ibfk_2\""
}
But when I use the SQL editor and do the same insert with:
INSERT INTO resource_purchase (server_id, resource_id, price, email) VALUES (868241175688151051, 9628, 0.00, 'tanner_test@gmail.com');
It inserts the row correctly. Are these not doing the exact same thing?
For reference, the constraint is:
CONSTRAINT resource_purchase_ibfk_2 FOREIGN KEY (server_id) REFERENCES discord_server (server_id)
and the server_id I am inserting is in discord_server table as a row already so it should not be violated (and clearly it isn't when using the SQL Editor in the UI)kyds3k
01/31/2023, 11:33 PMnateland
02/01/2023, 2:07 AMuser8923
02/01/2023, 3:18 AMalana
02/01/2023, 3:44 AM${fence}
02/01/2023, 4:59 AMJamesB
02/01/2023, 5:59 AM${fence}
02/01/2023, 6:53 AMHolland
02/01/2023, 7:02 AMconst { data, error } = await supabaseClient.auth.signInWithOAuth({
provider: 'google',
})
2. Attempt to get user
const userInfo = await supabaseClient.auth.getUser()
3. Get error message
data: {user: null}
error: AuthApiError: invalid claim: missing sub claim at eval (webpack-internal:///.
name:"AuthApiError"
status: 401
__isAuthError: true
message:"invalid claim: missing sub claim"
stack: "AuthApiError: invalid claim: missing sub claim
at eval (webpack-internal:///./node_modules/@supabase/gotrue-js/dist/module/lib/fetch.js:49:20)"
What I am using I am using Next.js. I installed the following:
@supabase/auth-helpers-nextjs
@supabase/auth-helpers-react
@supabase/auth-ui-react
Note
Logging in and signing up with email and password work fine for me. I call signUp to create a user with email and password and signInWithPassword to log them in with email and password. Calling supabaseClient.auth.getUser() after logging in with email and password returns a user for me.
I am confused on how to actually impliment a signup with google. As I only see the function for signInWithGoogle(). How do I signin and signup with google?
I click sign in with google. In the console the log quickly flashes a printout occuring after I await signInWithOAuth. Then I choose google account. Then it even redirects me to the / route. Then I try to getUser() and get same error. Then I try to getSession() which returns data:session = null. So no session.
Logging in with email and password gives a session and user. My account I am using to log in with google is currently a user with Provider=Google in the app.supabase.com Authentication tab.Tiago
02/01/2023, 7:21 AMprofiles
table with the following RLS:
create policy "Profiles are viewable by users who created them."
on profiles for select
using ( auth.uid() = id );
create policy "Users can insert their own profile."
on profiles for insert
with check ( auth.uid() = id );
create policy "Users can update own profile."
on profiles for update
using ( auth.uid() = id );
I am using NEXTJS and created a protected route /page/about/index.js
where I am would like to get the user 's details. For that I was thinking getting it on getServerSideProps
as follows:
export const getServerSideProps = async () => {
const { data } = await supabase.from("profiles").select("*");
return {
props: {
data: data ?? [],
},
};
};
This however is getting me an empty array.
Any idea how to access a private profile for the user that is authenticated?
Thank you.jinsley8
02/01/2023, 8:38 AMjsonb
column. Something like below where I need name
from the metadata
column.
Is this possible?
sql
ALTER TABLE public.items ADD COLUMN fts tsvector GENERATED ALWAYS AS (to_tsvector('english', token_id || ' ' || metadata->>name)) stored;
CREATE INDEX item_fts ON public.items USING GIN (fts);
JamesB
02/01/2023, 8:56 AMsql
create policy "User with X role can select role membership from other users"
on role_members
to authenticated
using (
auth.uid() <> user_id and
auth.uid() in (
select role_members.user_id
from role_members
where
role_members.user_id = auth.uid() and
role_members.role_id in (
select roles.id
from roles
where
name in (
'admin',
'profile_viewer',
'profile_editor'
)
)
)
)
I don't understand why this is marked as an infinite recursion. Somebody else here who sees the issue? And how I'd work around it? Thanks!