Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to delete a team account? #87

Open
haramishra opened this issue May 8, 2024 · 3 comments
Open

how to delete a team account? #87

haramishra opened this issue May 8, 2024 · 3 comments

Comments

@haramishra
Copy link

I couldn't find the API to delete a team account on base jump docs. Please help me out.

@qnsi
Copy link

qnsi commented May 21, 2024

1. Add new policy on basejump.accounts

"Account can be deleted by primary owner" with check " (primary_owner_user_id = auth.uid())"

2. Expose basejump scheme from API

Go to settings -> Api -> Exposed schema and add basejump here

!! Warning, make sure your policies are correct. I did only a brief check and it seems basejump has sane defaults, but the risk is on you.

3. Query from client using basejump and not public schema

      const { data, error } = await supabase
        .schema("basejump")
        .from("accounts")
        .delete()
        .eq("id", workspaceId);

@airsherlock
Copy link

We do not wish to expose the entire basejump schema public as mentioned above.

Is there a function / rest api to delete the team?

@vbylen
Copy link

vbylen commented Aug 15, 2024

@airsherlock I think you'd have to write the function yourself.

Something like this:

**
  Allows an owner to delete an existing account
 */

create or replace function public.delete_account(account_id uuid)
    returns void
    language plpgsql
as
$$
begin
    -- verify account owner for the account
    if basejump.has_role_on_account(
               delete_account.account_id, 'owner') <>
       true then
        raise exception 'Only account owners can delete accounts';
    end if;

    delete from basejump.accounts where id = delete_account.account_id;
end
$$;

grant execute on function public.delete_account(uuid) to authenticated;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants