File tree Expand file tree Collapse file tree
services/registration/src/routes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,11 +183,14 @@ applicationRouter.route("/:id").delete(
183183 throw new BadRequestError ( "Application not found or you do not have permission to delete." ) ;
184184 }
185185
186- console . log ( "application userId" , application . userId ) ;
187- console . log ( "req user uid" , req . user ?. uid ) ;
186+ const allowedStatus = [ StatusType . DRAFT , StatusType . APPLIED ] ;
188187 // Ensure only the owner or an authorized admin can delete
189188 if ( application . userId !== req . user ?. uid && ! req . user ?. roles . member ) {
190189 throw new BadRequestError ( "You do not have permission to delete this application." ) ;
190+ } else if ( ! allowedStatus . includes ( application . status ) ) {
191+ throw new BadRequestError (
192+ "You can only delete an application if the status is a draft or applied."
193+ ) ;
191194 }
192195
193196 await ApplicationModel . findByIdAndDelete ( req . params . id ) ;
You can’t perform that action at this time.
0 commit comments