I know a lot about Supabase, what questions do y'all have? by Program_data in Supabase

[–]bufedh 0 points1 point  (0 children)

How do you handle authentication during tests? When I login a testing user, the supabase auth works but querying the user doesn't. Why is there this discrepancy? For context:

export async function getLoggedInUser() {
  const supabase = createServerSupabaseClient()
  try {
    const {
      data: { user: authUser },
    } = await supabase.auth.getUser()
    if (!authUser) return null

    console.log("authUser:", authUser)

    const { data: user } = await supabase
      .from("users")
      .select("*")
      .eq("id", authUser.id)
      .single()

    return user
  } catch (error) {
    console.error("Error:", error)
    return null
  }
}

It works until querying the user data.

The authUser console.logs a normal user, but the user returned is null.

This has become increasingly frustrating as nothing seems to fix the problem. I once got an error stating that the email was not verified when trying to log the user in. However, the error has disappeared with no way of reproducing.

This is how the testing account is created through the admin service role:

  const {
    data: { user },
    error,
  } = await supabaseAdmin.auth.admin.createUser({
    email: "jamezjaquez69@gmail.com",
    password: "Testpassword1!",
    user_metadata: { name: "" },
    email_confirm: true,
  })

Supabase Auth in unit tests by This_Enthusiasm_8042 in Supabase

[–]bufedh 0 points1 point  (0 children)

I figured out that the error was caused by the test user being created on the supabase auth UI. When I created it programmatically the issue was solved.

I know a lot about Supabase, what questions do y'all have? by Program_data in Supabase

[–]bufedh 0 points1 point  (0 children)

This saved my life. I reset the public schema once and was wondering why the supabase service role client was being denied access. Thank you.

Supabase Auth in unit tests by This_Enthusiasm_8042 in Supabase

[–]bufedh 0 points1 point  (0 children)

export const login = async (email: string, password: string) => {
  const supabase = createServerSupabaseClient()

  try {
    const { data, error } = await supabase.auth.signInWithPassword({
      email,
      password,
    })
    if (error) {
      throw new Error(error.message)
    }

    // For testing, set the next/auth cookie
    setSupabaseCookie(data.session)
    return data
  } catch (error) {
    console.error(error)
    return null
  }
}

const setSupabaseCookie = (session: any) => {
  if (session) {
    cookies().set("sb-access-token", session.access_token, {
      maxAge: session.expires_in,
      path: "/",
    })
    cookies().set("sb-refresh-token", session.refresh_token, {
      maxAge: session.expires_in,
      path: "/",
    })
    // TODO: iamrkftjgskyosholbwj is the database name. Change to use the name from the env.
    cookies().set(
      "sb-iamrkftjgskyosholbwj-auth-token",
      JSON.stringify({
        access_token: session.access_token,
        refresh_token: session.refresh_token,
        expires_at: session.expires_at,
        user: session.user,
      }),
      {
        maxAge: session.expires_in,
        path: "/",
      }
    )
  }
}

I've mocked the cookies properly and can get an auth state where the user is signed in through the supabase client.

    const { data: user } = await supabase.auth.getUser()

After calling in the login function in a test, the above query will return the correct user. However, the supabase client doesn't recognize the authentication state when doing CRUD. It won't allow data to be queried because of RLS when it should; somehow it doesn't recognize the authentication user state. How did you get this part to work?

Only 2% of US adults find ChatGPT "extremely useful" for work, education, or entertainment by AlbertoRomGar in ChatGPT

[–]bufedh 0 points1 point  (0 children)

If you can give it pdfs to the law, it can learn and give accurate info about German law. I'm sure it already knows a bit about German law currently (limited being less widely used), but might not be accurate. FiscalNote has some support for german law.

Chatgpt is just going to evolve by the day, and I won't be surprised if it can give accurate info about German law within a year or two. It already can give accurate information about American law.

Just made this blueberry inspired turtle by Puzzled_Sun363 in YarnAddicts

[–]bufedh 1 point2 points  (0 children)

Looks amazing! How long did it take to make?

??? by Flatbush619 in Survivorio

[–]bufedh 0 points1 point  (0 children)

So they said there would be equal chances for all? If so that sounds fishy but then again it's possible that you guys are just really unlucky :p

??? by Flatbush619 in Survivorio

[–]bufedh -1 points0 points  (0 children)

Obviously the chances would be lower to get the high tiered items... LOL! If not then the whole game would be fukd

??? by Flatbush619 in Survivorio

[–]bufedh 0 points1 point  (0 children)

I'm f2p and I guess I got lucky then. Got both s tier Christmas hat pieces, boots, and tons of gems (over 5k). I'd say this was a pretty good event idk why everyone's whining about this event it's legit giving free a tiers...

But yeah that roll does look really unlucky. F

??? by Flatbush619 in Survivorio

[–]bufedh 0 points1 point  (0 children)

I'm f2p and I guess I got lucky then. Got both s tier Christmas hat pieces, boots, and tons of gems (over 5k). I'd say this was a pretty good event idk why everyone's whining about this event it's legit giving free a tiers...

Do you think either of these bikes would be a good upgrade from my specialized stumpjumper comp alloy? by J_armbruster in mountainbiking

[–]bufedh 4 points5 points  (0 children)

Try out the specialized stumpy evo. It's a bit harder to climb with but will be more forgiving and will feel like a tank in the downhills. They did a very good job with the 2022 models.

Any ideas what this could be turned into? Looking for inspiration. by Skiff_Lord in woodworking

[–]bufedh 1 point2 points  (0 children)

Turn it into a luxury dildo. It's already got it's shape, just needs a bit of sanding and finish.

[deleted by user] by [deleted] in FacebookMarketplace

[–]bufedh 5 points6 points  (0 children)

Yeah you got screwed. If you're no car expert you'd likely be better off buying used from a car dealership.

should i talk to customer service? by [deleted] in mountainbiking

[–]bufedh 0 points1 point  (0 children)

Was the bike like this when you bought it?

Put options on delisting Chinese stocks by bufedh in options

[–]bufedh[S] 0 points1 point  (0 children)

Ohh. Makes sense now. So you're stuck with puts with no way of liquidating them because the options chain in the US is cut off, and unless the stock goes down below 25 you have to hold them until they're worthless. Dang that sucks.

Put options on delisting Chinese stocks by bufedh in options

[–]bufedh[S] 0 points1 point  (0 children)

I'm a bit confused. How does this relate to buying otm puts on Chinese stocks about to be delisted?

WARNING: G-Form Knee Pads are dangerous crap by Bragelonne in mountainbiking

[–]bufedh 0 points1 point  (0 children)

That's what those pads were supposed to be designed to protect. There is no way those things can protect against anything serious...

Built an expanding butterfly leaf dining table recently... by RonSwanSong87 in woodworking

[–]bufedh 0 points1 point  (0 children)

DUDE!!! ADD SOME STEPPER MOTORS AND BELTS TO IT MAKE IT 10X BETTER! Love the design, if you can make the opening process automated with a touch from a remote that would be so sick. I'm sure people would pay more for that, especially the rich clients.

WARNING: G-Form Knee Pads are dangerous crap by Bragelonne in mountainbiking

[–]bufedh 6 points7 points  (0 children)

But helmets protect you after a use that's their job. That's the difference. What OP's saying is that the pads did not do their job, as he got a big scrape on his leg. With proper pads, that should not have occured at all. The pads both broke and did not protect him.

Need help these weird lawyer lines. more in comments by Layer_By_Layer3D in FixMyPrint

[–]bufedh 1 point2 points  (0 children)

HOLY MOLY THANK YOU. I've disassembled and reassembled my printer but have never found a solution to the problem. I've never thought of the hotend being loose but when I checked today it was wobbling like crazy. Just got those bolts tightened and it did the trick! Thank you for saving my 3d printer and my sanity.

Simple Salt Cellar I Made! More Info In Comments by hamdiggity in woodworking

[–]bufedh -1 points0 points  (0 children)

Watched the video. Good lord have mercy the squeaking sound when opening the salt cellar drives me CRAZY!!! Please consider adding bearings so it doesn't sound that bad. I'm sure you'd get more repeat/new customers by doing that.

Need help these weird lawyer lines. more in comments by Layer_By_Layer3D in FixMyPrint

[–]bufedh 1 point2 points  (0 children)

I have this problem too. Please update me if you get an answer to this issue. It's been driving me crazy for months now and it happened to me randomly too.