File tree Expand file tree Collapse file tree
components/dashboard/settings/profile Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,11 +44,7 @@ export const DeleteAccount = () => {
4444 const email = data ?. user ?. email ?? "" ;
4545 const isBusy = requestCode . isPending || deleteAccount . isPending ;
4646
47- if (
48- ! data ||
49- hasPassword === undefined ||
50- ( ! isCloud && data . role === "owner" )
51- ) {
47+ if ( ! isCloud || ! data || data . role !== "owner" || hasPassword === undefined ) {
5248 return null ;
5349 }
5450
@@ -96,12 +92,10 @@ export const DeleteAccount = () => {
9692 </ CardHeader >
9793 < CardContent className = "flex flex-col gap-4" >
9894 < ul className = "text-sm text-muted-foreground list-disc pl-5 space-y-1" >
99- { isCloud && (
100- < li >
101- Active subscriptions are cancelled immediately. Invoices already
102- issued are kept for accounting.
103- </ li >
104- ) }
95+ < li >
96+ Active subscriptions are cancelled immediately. Invoices already
97+ issued are kept for accounting.
98+ </ li >
10599 < li >
106100 Every organization you own is deleted, including its projects,
107101 services, environments, domains and server connections.
Original file line number Diff line number Diff line change @@ -85,25 +85,29 @@ const assertCanDeleteOwnAccount = async (ctx: {
8585 user : { id : string } ;
8686 session : { impersonatedBy ?: string } ;
8787} ) => {
88+ if ( ! IS_CLOUD ) {
89+ throw new TRPCError ( {
90+ code : "BAD_REQUEST" ,
91+ message : "This feature is only available in Dokploy Cloud" ,
92+ } ) ;
93+ }
94+
8895 if ( ctx . session . impersonatedBy ) {
8996 throw new TRPCError ( {
9097 code : "FORBIDDEN" ,
9198 message : "Accounts cannot be deleted while impersonating" ,
9299 } ) ;
93100 }
94101
95- if ( ! IS_CLOUD ) {
96- const ownedOrganization = await db . query . organization . findFirst ( {
97- where : eq ( organization . ownerId , ctx . user . id ) ,
98- columns : { id : true } ,
102+ const ownedOrganization = await db . query . organization . findFirst ( {
103+ where : eq ( organization . ownerId , ctx . user . id ) ,
104+ columns : { id : true } ,
105+ } ) ;
106+ if ( ! ownedOrganization ) {
107+ throw new TRPCError ( {
108+ code : "FORBIDDEN" ,
109+ message : "Only organization owners can delete their account" ,
99110 } ) ;
100- if ( ownedOrganization ) {
101- throw new TRPCError ( {
102- code : "FORBIDDEN" ,
103- message :
104- "Transfer or delete the organizations you own before deleting your account" ,
105- } ) ;
106- }
107111 }
108112} ;
109113
You can’t perform that action at this time.
0 commit comments