Improve 'Leave Team' process with logging and confirmation step

Added logging to the 'Leave Team' functionality to track user actions, and implemented a confirmation input to further validate a user's intent to leave a team. Also revised the user-facing prompt for more clarity on the team leaving process. Corresponding changes were applied to the relevant services and front-end components.
This commit is contained in:
giancarlo
2024-03-29 16:40:44 +08:00
parent 2b0fbc445b
commit 9e06d420bd
5 changed files with 120 additions and 23 deletions

View File

@@ -453,6 +453,22 @@ delete on table public.accounts_memberships to service_role;
-- Enable RLS on the accounts_memberships table
alter table public.accounts_memberships enable row level security;
-- Trigger to prevent a primary owner from being removed from an account
create
or replace function kit.prevent_account_owner_membership_delete () returns trigger as $$
begin
if exists (select 1 from public.accounts where id = old.account_id and primary_owner_user_id = old.user_id) then
raise exception 'The primary account owner cannot be removed from the account membership list';
end if;
return old;
end;
$$ language plpgsql;
create or replace trigger prevent_account_owner_membership_delete_check before delete
on public.accounts_memberships for each row
execute function kit.prevent_account_owner_membership_delete ();
create
or replace function public.has_role_on_account (
account_id uuid,
@@ -572,6 +588,8 @@ using (
)
);
/*
* -------------------------------------------------------
* Section: Account Roles