feat(api): create endpoint to ban/unban a user
yeeting is now possible :D
This commit is contained in:
		
							parent
							
								
									d67530eb64
								
							
						
					
					
						commit
						309e880b69
					
				
							
								
								
									
										19
									
								
								server/api/user/[id]/ban.post.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								server/api/user/[id]/ban.post.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | |||||||
|  | import isAdmin from "~/lib/server/middlewareButNotReally/isAdmin"; | ||||||
|  | import isLoggedIn from "~/lib/server/middlewareButNotReally/isLoggedIn"; | ||||||
|  | import { User } from "~/models/user"; | ||||||
|  | 
 | ||||||
|  | export default eventHandler(async (ev) => { | ||||||
|  | 	isLoggedIn(ev); | ||||||
|  | 	isAdmin(ev); | ||||||
|  | 	const body = await readBody(ev); | ||||||
|  | 	let idee = parseInt(getRouterParam(ev, "id")!); | ||||||
|  | 	await User.findByIdAndUpdate(idee, { | ||||||
|  | 		$set: { | ||||||
|  | 			banned: body.ban, | ||||||
|  | 		}, | ||||||
|  | 	}); | ||||||
|  | 	return { | ||||||
|  | 		success: true, | ||||||
|  | 		banned: body.ban, | ||||||
|  | 	}; | ||||||
|  | }); | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user