cohlar
05/04/2023, 4:39 PMapp-staging
and app-prod
, each deployed to a separate domain, but sometimes when I click the login
button in app-staging
, I get (successfully) logged into app-prod
... and the weirdest thing is that it's only sometimes - sometimes it logs me into app-staging
as expected. And it never happens the other way around (thank god!) - app-prod
login always routes to app-prod
, app-staging
login routes sometimes to app-staging
and sometimes to app-prod
🤯
I use exclusively Google OAuth to log into the app, and I have created two separate OAuth Client ID's in the Google console - one for each environment. I have already checked the following (multiple times):
- I use supabase.auth.signInWithOAuth({ provider: 'google' })
to login, and each environment has the right instance of supabase (i.e. with the right respective supabase url and anon key)
- each Google OAuth Client ID only has one single domain as "Authorized Javascript origins" and as "Authorized redirect URIs" (respectively the staging / prod domain)
- in supabase studio, each project has Google auth configured with their respective Client ID and Client Secret (different)
- in supabase studio, each project has the right Site URL (different) set in the Authentication URL Configuration
- I have tried with different browsers / devices, the same issue occurs
Any idea where it could come from or what else I could check / do?
Thanks for your help 🙏🏻matth
05/04/2023, 4:41 PMven
05/04/2023, 4:53 PMven
05/04/2023, 5:23 PMhttps://cdn.discordapp.com/attachments/1103733533387804833/1103733533568155648/logflare_error..png▾
Shjba
05/04/2023, 6:28 PMrealtime-py
to trigger the event INSERT from the table. So I can not get the data from the table. See the attachment below, how can I fix that?
https://cdn.discordapp.com/attachments/1103749889105592381/1103749889319518290/342684574_211589628286554_9002287015538099305_n.png▾
Byron
05/04/2023, 6:53 PMhttps://cdn.discordapp.com/attachments/1103756281015189524/1103756281178763274/Screenshot_2023-05-04_at_2.52.45_PM.png▾
probo
05/04/2023, 7:41 PMbensurf
05/04/2023, 7:49 PMkevlust
05/04/2023, 7:51 PMsascha
05/04/2023, 9:27 PMhttps://cdn.discordapp.com/attachments/1103795104839389204/1103795105237844058/Screenshot_2023-05-04_at_23.26.25.png▾
https://cdn.discordapp.com/attachments/1103795104839389204/1103795105720193064/Screenshot_2023-05-04_at_23.26.50.png▾
https://cdn.discordapp.com/attachments/1103795104839389204/1103795106148007957/Screenshot_2023-05-04_at_23.27.04.png▾
https://cdn.discordapp.com/attachments/1103795104839389204/1103795106546454638/Screenshot_2023-05-04_at_23.27.13.png▾
ffkml
05/04/2023, 9:29 PMbsgbryan
05/04/2023, 9:56 PMKiwiHour
05/04/2023, 10:05 PMts
createClient<SupabaseSchema>(SUPABASE_URL, SUPABASE_ANON_KEY, { auth: { persistSession: false } })
I confirm a user is logged in like so
ts
const { data: { user }, error } = await supabase.auth.getUser()
if (error) throw error;
if (!user) throw redirect(303, "/login")
I have also tried using getSession
instead of getUser
but it always returns null. I've tried all the variations on which way to login / check logged in for users.
Just need someone to point me in the direction of the actual correct way to do all this authentication. There's so many conflicting answers on the internet and none of them are working for meSnarloff
05/05/2023, 12:26 AMKiwiHour
05/05/2023, 12:59 AM/update-password
And my hooks.server.ts
marks the user has not being logged in, so redirects them to /login
But after that redirect to the login page, if I go back to /update-password
manually via the search bar, it says that I'm logged in and lets me update my password just fine.
It's almost like it takes half a second to login the user, enough time to fool the hook into thinking they aren't logged in
Here's is the relevant code
hooks.server.ts
ts
// Supabase setup
event.locals.supabase = createSupabaseServerClient<SupabaseSchema>({
supabaseUrl: PUBLIC_SUPABASE_URL,
supabaseKey: PUBLIC_SUPABASE_ANON_KEY,
event
});
event.locals.getSession = async () => {
const { data: { session } } = await event.locals.supabase.auth.getSession();
return session;
};
// Unimportant code
event.locals.profile = new Profile(event.locals.supabase)
if (noLoginRoutes.includes(event.url.pathname)) return await resolve(event);
// This is where the request is checked to see if they are logged in or not
if (!await event.locals.getSession()) { console.log("not logged in"); throw redirect(303, "/login") }
return await resolve(event);
reset-password/+page.server.ts
ts
const { data, error } = await locals.supabase.auth.resetPasswordForEmail(email, {
redirectTo: url.origin + "/update-password"
});
if (error) return fail(500, { error: { message: error.message } })
The update-password
route works a-ok, the main issue lies in the hook
Should I just allow users that aren't logged in to update passwords, add a 1 or 2 second timeout before checking if they are logged in (terrible idea probably) or figure out why the hook is falsely thinking a user isn't logged in when they are?ven
05/05/2023, 1:23 AMhttps://cdn.discordapp.com/attachments/1103854491234742293/1103854491742245044/image.png▾
https://cdn.discordapp.com/attachments/1103854491234742293/1103854492081979403/deno_docker_logs.png▾
GHOST
05/05/2023, 2:23 AMjs
const guild_result = await supabase.from('user_guild').select(`
guild_id,
enabled,
guild (
guild_name,
icon
)
`);
And it returns a structure like:
js
[
{
guild_id: '',
enabled: false,
guild: {
guild_name: '',
icon: ''
}
}
]
Is possible for it to return
js
[
{
guild_id: '',
enabled: false,
guild_name: '',
icon: ''
}
]
j3llybeans
05/05/2023, 10:01 AMAlexBThomsen
05/05/2023, 10:35 AMEpailes
05/05/2023, 11:33 AMEpailes
05/05/2023, 12:35 PMIF session_user = 'authenticator'
, how can I know what the invoker is?garyaustin
05/05/2023, 12:59 PMYuu
05/05/2023, 1:00 PMcreateClient
in the service worker again? I want it to be authenticated as I'm using this for realtime notifications, based on events from postgresfabio
05/05/2023, 1:19 PMSTILLWATER;
05/05/2023, 1:23 PMfabio
05/05/2023, 2:07 PMlmjcbs
05/05/2023, 2:46 PMInvalid SQL query
when testing creating virtual generated fields, but works ok when creating STORED
variants?
Ideally the functionality I'm really after is something similar to:
// Boolean flag for featured posts published within the last 7 days
ALTER TABLE posts ADD COLUMN is_pinned boolean GENERATED ALWAYS AS
(CASE WHEN published_at IS NULL OR NOT featured THEN FALSE ELSE published_at >= CURRENT_DATE - INTERVAL '7 days' END);
Revaycolizer
05/05/2023, 2:51 PMconst [vname,setVname] = useState('')
const [vfile,setVfile] = useState<File |null>(null)
const [selectedValue, setSelectedValue] =useState({category:'dance'})
const [open,setOpen] =useState(false)
const [file_url,setFile_url] = useState<any | null>(null)
const [user,setUser] = useState<any | null>(null)
const [downloads,setDownload] =useState<any | null>(null)
const [dfiles,setDfiles] = useState<any | null>(null)
const router = useRouter()
useEffect(()=>{
User()
fetchPosts()
},[])
const User =useCallback(async()=>{
const {data:{user}} = await supabase.auth.getUser()
if(user){
const userId = await supabase.from("profiles").select('id').eq('email',user.email)
setUser(userId.data)
console.log(user)
}
},[])
rogerclark
05/05/2023, 3:33 PMimagio
05/05/2023, 3:38 PM