feat(org): prevent removal of last organization owner
Add validation in OrganizationService to check if the member being removed is the last owner of an organization. If so, raise a ValueError to prevent accidental loss of ownership. The API layer catches this exception and returns a 403 error with appropriate message.
This commit is contained in:
@@ -876,6 +876,30 @@ export default function MembersPage() {
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
||||
{/* ── Remove member confirmation dialog ───────────────────────────────────── */}
|
||||
<Dialog open={removeMember !== null} onOpenChange={(open) => !open && setRemoveMember(null)}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
<AlertTriangle className="w-5 h-5 text-destructive" />
|
||||
Remove member from organization?
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
This will remove {removeMember?.user?.full_name || removeMember?.user?.email} from the organization. This action cannot be undone.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setRemoveMember(null)} disabled={isRemoving}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button variant="destructive" onClick={handleRemoveMember} disabled={isRemoving}>
|
||||
{isRemoving && <Loader2 className="w-4 h-4 mr-2 animate-spin" />}
|
||||
Remove member
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* ── User detail drawer ──────────────────────────────────────────────────── */}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user