EKI
05/23/2023, 4:59 PMDan Rumney
05/23/2023, 5:03 PM--trace-block-coverage
v8 flag to deno run
.
Is there an equivalent process for doing this with the edge-runtime
command?vikay
05/23/2023, 5:24 PMArjunXD
05/23/2023, 5:49 PMhttps://cdn.discordapp.com/attachments/1110625540886495313/1110625541020729415/image.png▾
yayza_
05/23/2023, 6:00 PMChez
05/23/2023, 6:26 PMhttps://cdn.discordapp.com/attachments/1110634802073317396/1110634802257858711/auth_attempt.png▾
https://cdn.discordapp.com/attachments/1110634802073317396/1110634802572427294/auth_functions.png▾
https://cdn.discordapp.com/attachments/1110634802073317396/1110634802895400960/auth_triggers.png▾
https://cdn.discordapp.com/attachments/1110634802073317396/1110634803277070516/auth_url.png▾
https://cdn.discordapp.com/attachments/1110634802073317396/1110634803662958612/auth_users.png▾
vikay
05/23/2023, 6:34 PMjs
import { useRouter } from 'next/router';
import { useState, useEffect } from 'react';
import supabase from '@/components/supabase';
export default function Auth2() {
const router = useRouter();
const [session, setSession] = useState('');
useEffect(async () => {
const data = await supabase.auth.getSession();
if (!data) return;
setSession('GetData');
}, []);
supabase.auth.onAuthStateChange(async (event) => {
if (event === "SIGNED_IN") {
router.push('/dashboard');
}
if (event === 'SIGNED_OUT') {
router.push("/");
}
});
async function signInWithDiscord() {
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'discord',
options: {
scopes: 'identify guilds'
}
});
}
async function signout() {
const { error } = await supabase.auth.signOut();
}
if (session === "GetData") {
signout();
} else {
signInWithDiscord();
}
}
Dilly
05/23/2023, 6:45 PMRevaycolizer
05/23/2023, 7:24 PMmatteo6b
05/23/2023, 10:41 PMDDupasquier
05/23/2023, 11:48 PMjson
{
"user": {
"id": "21cd995a-84ae-42f3-a9e8-3cd48074ba84",
"aud": "authenticated",
"role": "authenticated",
"email": "ihopethisworks@gmail.com",
"phone": "",
"confirmation_sent_at": "2023-05-23T23:38:06.314959404Z",
"app_metadata": {
"provider": "email",
"providers": [
"email"
]
},
"user_metadata": {},
"identities": [
{
"id": "21cd995a-84ae-42f3-a9e8-3cd48074ba84",
"user_id": "21cd995a-84ae-42f3-a9e8-3cd48074ba84",
"identity_data": {
"email": "ihopethisworks@gmail.com",
"sub": "21cd995a-84ae-42f3-a9e8-3cd48074ba84"
},
"provider": "email",
"last_sign_in_at": "2023-05-23T23:38:06.312979098Z",
"created_at": "2023-05-23T23:38:06.313013Z",
"updated_at": "2023-05-23T23:38:06.313013Z"
}
],
"created_at": "2023-05-23T23:38:06.310532Z",
"updated_at": "2023-05-23T23:38:06.737187Z"
},
"session": null
}
I'm wondering if there's a way to access the role key in this JSON object and change it to a specific role such as Admin or Lead.
Additionally, I would appreciate recommendations on the best approach to assign roles in this scenario. Should I have each user create their own profile and assign their roles, or is it better to have the organization or designated administrators create and assign roles to users? Since this application is intended as an internal tool, it seems logical for the organization to manage account creation and role assignments. What would be the recommended approach for implementing role-based access control?
I'm having trouble finding information on how to achieve this and where to start. Any guidance or clarification would be greatly appreciated!King
05/23/2023, 11:49 PMhttps://cdn.discordapp.com/attachments/1110716145054515210/1110716145171959828/neww.png▾
navarrobedoya
05/24/2023, 12:07 AMalana
05/24/2023, 12:39 AMuseUser()
function? or any examples you can point me to for how to access user data when signed in? simple use case is just showing an account page with profile info when a user signs in. thank you!mansedan
05/24/2023, 1:09 AMhelmik
05/24/2023, 1:11 AMbdz
05/24/2023, 2:30 AMhttps://cdn.discordapp.com/attachments/1110756575238426724/1110756575506866186/Screenshot_2023-05-23_at_10.27.56_PM.png▾
https://cdn.discordapp.com/attachments/1110756575238426724/1110756575855005756/Screenshot_2023-05-23_at_10.29.30_PM.png▾
https://cdn.discordapp.com/attachments/1110756575238426724/1110756576186339379/Screenshot_2023-05-23_at_10.29.38_PM.png▾
ostoto
05/24/2023, 2:33 AMcaseycrogers
05/24/2023, 2:53 AMprimaryKey
does.
For example, I have a table with the syntax id | created_at | user_id | ...
where id
is the primary key. How do I write a query that returns events for the most recent row for a given user_id
? The following is what I wrote but I'm not getting any updates after the first event and my best guess is it's because of primaryKey
but primaryKey
is almost entirely undocumented so I'm not sure...
dart
return supabase.from('myTable')
.stream(primaryKey: [idCol])
.eq(anonIdCol, anonId)
.order(createdAtCol, ascending: false)
.limit(1);
zach
05/24/2023, 3:01 AMhttps://cdn.discordapp.com/attachments/1110764363406659594/1110764363834466335/Screenshot_2023-05-23_at_10.59.13_PM.png▾
https://cdn.discordapp.com/attachments/1110764363406659594/1110764364182601768/Screenshot_2023-05-23_at_10.58.51_PM.png▾
vikay
05/24/2023, 4:27 AMDubC
05/24/2023, 4:28 AMhttps://cdn.discordapp.com/attachments/1110786369783083059/1110786369892126840/image.png▾
coop
05/24/2023, 5:32 AMvikay
05/24/2023, 6:53 AMhttps://cdn.discordapp.com/attachments/1110822979811688559/1110822979950092329/Screenshot_2023-05-24_122132.png▾
drilkmops
05/24/2023, 7:18 AMIf Confirm email is enabled in your project, an obfuscated/fake user object is returned.
I'm essentially just trying to do this flow:
- let users fill out form without creating account
- on fill out of form, prompt to sign up
- on sign up success i save the form data to my backend
Just trying to make it as simple to onboard folks as I can!
https://supabase.com/docs/reference/javascript/auth-signupiqn
05/24/2023, 7:27 AMCrembo
05/24/2023, 8:08 AMREVOKE INSERT, UPDATE ON table FOR authenticated
GRANT INSERT (col1, col2, ... all the columns except created_at) ON table FOR authenticated
)
Am I missing a flag?huksley
05/24/2023, 8:29 AMmattposgate
05/24/2023, 8:34 AMShadowOP
05/24/2023, 9:05 AMjs
export async function signInWithDiscord(afterSignIn) {
const { data, error } = await supabase.auth.signInWithOAuth({ provider: "discord" })
if (error) {
console.error("Authorization failed:", error.message)
return
}
if (data) {
if (afterSignIn) {
afterSignIn()
}
}
}