Edits history of script submission #22563 for ' Authenticate with email and password (supabase)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { createClient } from "@supabase/[email protected]"
    
    type Supabase = {
      url: string;
      key: string;
    };
    export async function main(auth: Supabase, email: string, password: string) {
      const client = createClient(auth.url, auth.key);
      const { data, error } = await client.auth.signInWithPassword({
        email,
        password,
      });
      if (error) {
        return {
          access_token: undefined,
          refresh_token: undefined,
          error: error.message,
        };
      }
      return {
        access_token: data?.session?.access_token,
        refresh_token: data?.session?.refresh_token,
        error: undefined,
      };
    }
    

    Submitted by hugo989 3 days ago