jacobL
10/15/2022, 8:43 PMNeki
10/15/2022, 11:39 PMczypnt
10/16/2022, 12:45 AMuser8923
10/16/2022, 1:37 AMts
// index.tsx
import { User, withPageAuth } from "@supabase/auth-helpers-nextjs";
type HomePageProps =
{
user: User;
};
export default function HomePage({ user }: HomePageProps)
{
return <div>Hello { user.email }</div>;
}
export const getServerSideProps = withPageAuth({ redirectTo: "/login" });
user8923
10/16/2022, 3:40 AMjs
export const getServerSideProps = withPageAuth({ redirectTo: ("/login") });
After authentication in the /login page, I can't figure out how to route back to the previous page. I don't want to have to manually add a "referrer" query parameter in the redirectTo field, and I also want the ability to include any possible query params or anchors that existed in the previous page's URL. I can't use router.back() because apparently the redirection to the login page uses router.replace(), which doesn't write to browser history. Kinda stumped on this one!bazooka_penguin
10/16/2022, 3:46 AMrohanprasadofficial
10/16/2022, 4:20 AMoskiε¦
10/16/2022, 6:12 AMjkohlin
10/16/2022, 8:13 AMawait supabase
.from('notes')
.insert([
{
text: 'This is a test',
user_id: '123',
form_row: 1,
},
{
text: 'This is another test',
user_id: '123',
form_row: 3,
},
],
{
upsert: true,
onConflict: 'id',
ignoreDuplicates: false
})
.select()
but get this error :
null value in column "id" of relation "notes" violates not-null constraint
id
is auto increment
Can I use UPSERT this way?Armitage
10/16/2022, 10:02 AMAbhinav_MV
10/16/2022, 12:13 PMWarman
10/16/2022, 1:16 PMrobf120
10/16/2022, 1:32 PMchrisgrabinski
10/16/2022, 2:07 PMauth.users
table will be filled. I then used this information in my seed.sql
file. And while the users are actually showing up in the UI, when trying to log in (or sending a magic link from Studio), I am getting an Database error finding user
/ Failed to send magic link: Database error finding user
error.
Here's a snippet from my `seed.sql`:
sql
insert into auth.users (email, id, instance_id, aud, role, encrypted_password, invited_at, confirmation_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, created_at, updated_at, email_confirmed_at, email_change_confirm_status)
values
('user-1@example.com', 'bd59c1b6-949a-44fb-b0e1-fac10f7367a1', '00000000-0000-0000-0000-000000000000', 'authenticated', 'authenticated', '$2a$10$jFOTJvSGDgj5ImgfH3DLeezIZY6HOayJvlE80lY0VdVfdY.zo3h7u', now(), now(), now(), '{"provider":"email","providers":["email"]}', '{}', now(), now(), now(), 0),
('user-2@example.com', 'bd59c1b6-949a-44fb-b0e1-fac10f7367a2', '00000000-0000-0000-0000-000000000000', 'authenticated', 'authenticated', '$2a$10$jFOTJvSGDgj5ImgfH3DLeezIZY6HOayJvlE80lY0VdVfdY.zo3h7u', now(), now(), now(), '{"provider":"email","providers":["email"]}', '{}', now(), now(), now(), 0);
Am I missing something, or am I approaching this incorrectly?ven
10/16/2022, 2:59 PMTimedOut: Connection timed out (os error 110)
at async Object.connect (deno:ext/net/01_net.js:333:17)
at async SmtpClient.connect (file:///src/main.ts:857:22)
at async Server.<anonymous> (file:///src/main.ts:1173:5)
at async Server.#respond (file:///src/main.ts:111:24)
Severity
ERROR
Deployment version3
Timestamp16 Oct, 2022 09:41
Execution ID43ccbd3e-63eb-43bb-9ab6-06f58bc38ea0
here is the key section of the function
await smtp.connect({
hostname: String(Deno.env.get('SENDGRID_SMTP_HOSTNAME')),
port: Number(Deno.env.get('SENDGRID_SMTP_PORT')),
username: String(Deno.env.get('SENDGRID_SMTP_USERNAME')),
password: String(Deno.env.get('SENDGRID_SMTP_PASSWORD')),
});
try {
await smtp.send({
from: String(Deno.env.get('SENDGRID_SMTP_FROM')),
to: payload.to,
subject: payload.subject,
content: payload.content,
});
} catch (error) {
return new Response(error.message, { status: 500 });
}
await smtp.close();
Gipson62
10/16/2022, 3:38 PMjon.m
10/16/2022, 4:38 PMSQL
CREATE OR REPLACE FUNCTION fetch_user_details(usersid uuid)
RETURNS table(
user_detail_id bigint,
user_id uuid,
full_name text,
user_email text,
org_id bigint,
org_name text
) AS
$$
BEGIN
RETURN QUERY
SELECT
u.id,
u.user_id,
u.full_name,
u.user_email,
o.id,
o.org_name
FROM user_details u
INNER JOIN org_details o
ON u.org_id = o.id
WHERE u.user_id = usersid;
END
$$
language plpgsql;
DanM
10/16/2022, 6:10 PMDomcario
10/16/2022, 6:38 PMNanoBit
10/17/2022, 3:30 AMDanMossa
10/16/2022, 8:21 PMip
.
I have a postgres function that's calling API using HTTP and I'm putting the API key in that function. The IP address that's calling the HTTP req is 23.90.20.110
Will this ever change? Or can I reliably set the IP knowing it won't change?AlanK
10/16/2022, 10:35 PMimport { getSupabase } from '@supabase/auth-helpers-sveltekit';
import { error, redirect } from '@sveltejs/kit';
/** @type {import('./$types').Actions} */
export const actions = {
default: async (event) => {
const { request } = event;
const { session, supabaseClient } = await getSupabase(event);
console.log('supabaseClient', supabaseClient);
if (!session) {
// the user is not signed in
throw error(403, { message: 'Unauthorized' });
}
const formData = await request.formData();
const { data: profileData, error: profileError } = supabaseClient
.from('profile')
.update({
first_name: formData.get('first_name'),
family_name: formData.get('family_name'),
phone: formData.get('phone'),
mobile: formData.get('mobile'),
mobile_reception: parseInt(formData.get('mobile_reception')),
rfs_survival_plan: formData.get('rfs_survival_plan')
})
.eq('id', session.user.id);
console.log('profileData', profileData);
console.log('profileError', profileError);
if (profileError) {
console.log('update error profileAboutMe:', profileError);
throw error(400, profileError.message);
}
return {
user: session.user,
profileData
};
}
};
Both the session & supabaseClient seem fine, but after the update profileData, and profileError are both undefined.
Am I missing something?0xRice
10/17/2022, 1:27 AMsubscription
.
// pages/login.tsx
import { useSessionContext, useUser } from '@supabase/auth-helpers-react'
const LoginPage = (): JSX.Element => {
const { isLoading, session, error, supabaseClient } = useSessionContext()
const user = useUser()
if (isLoading || !user) {
return <>Not login</>
}
return (
<div className="flex h-screen">
<h1>Test</h1>
</div>
)
}
export default LoginPage
// _app.tsx
import '../styles/globals.css'
import type { AppProps } from 'next/app'
import { SessionContextProvider } from '@supabase/auth-helpers-react'
import { createBrowserSupabaseClient } from '@supabase/auth-helpers-nextjs'
const App = ({ Component, pageProps }: AppProps) => {
const [supabaseClient] = useState(() => createBrowserSupabaseClient())
return (
<SessionContextProvider
supabaseClient={supabaseClient}
initialSession={pageProps.initialSession}
>
<Component {...pageProps} />
</SessionContextProvider>
)
}
export default App
BoogersLLC
10/17/2022, 1:44 AMtextSearch
only matches whole words for me (Big only matches Big). Wondering what I'm possibly missing here?kvnfo
10/17/2022, 2:04 AMdeath_wears_bunny_slippers
10/17/2022, 2:20 AMdraco
10/17/2022, 5:40 AMupdateUser({password: 'some_password'})
, where do you add in the access_token
and other info from the url?
I have seen previously that you can pass the access_token into the updateUser function but in v2 that is no longer the case. So what do you do when the user is trying to do a password reset and doesn't have a current session going?kresimirgalic
10/17/2022, 7:41 AMMDobs
10/17/2022, 10:30 AMThoth Trismegistus
10/17/2022, 2:45 PM