Exposed deleting users, mostly for my own testing, and used it to make a primitive admin app. Add a handful of apps I've been kicking around without version control, while I'm at it.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3950 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		
							
								
								
									
										21
									
								
								core/core.js
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								core/core.js
									
									
									
									
									
								
							| @@ -224,6 +224,27 @@ async function getProcessBlob(blobId, key, options) { | ||||
| 					}, | ||||
| 				} | ||||
| 			}; | ||||
| 			if (process.credentials?.permissions?.administration) { | ||||
| 				imports.core.deleteUser = function(user) { | ||||
| 					return imports.core.permissionTest('delete_user').then(function() { | ||||
| 						let db = new Database('auth'); | ||||
|  | ||||
| 						db.remove('user:' + user); | ||||
|  | ||||
| 						let users = new Set(); | ||||
| 						let users_original = db.get('users'); | ||||
| 						try { | ||||
| 							users = new Set(JSON.parse(users_original)); | ||||
| 						} catch { | ||||
| 						} | ||||
| 						users.delete(user); | ||||
| 						users = JSON.stringify([...users].sort()); | ||||
| 						if (users !== users_original) { | ||||
| 							db.set('users', users); | ||||
| 						} | ||||
| 					}); | ||||
| 				} | ||||
| 			} | ||||
| 			if (options.api) { | ||||
| 				imports.app = {}; | ||||
| 				for (let i in options.api) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user