mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	fix: object destructuring overwriting type parameter
also check for valid types in generateExport
This commit is contained in:
		| @@ -443,6 +443,10 @@ usersAPI.changePicture = async (caller, data) => { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| usersAPI.generateExport = async (caller, { uid, type }) => { | usersAPI.generateExport = async (caller, { uid, type }) => { | ||||||
|  | 	const validTypes = ['profile', 'posts', 'uploads']; | ||||||
|  | 	if (!validTypes.includes(type)) { | ||||||
|  | 		throw new Error('[[error:invalid-data]]'); | ||||||
|  | 	} | ||||||
| 	const count = await db.incrObjectField('locks', `export:${uid}${type}`); | 	const count = await db.incrObjectField('locks', `export:${uid}${type}`); | ||||||
| 	if (count > 1) { | 	if (count > 1) { | ||||||
| 		throw new Error('[[error:already-exporting]]'); | 		throw new Error('[[error:already-exporting]]'); | ||||||
|   | |||||||
| @@ -74,6 +74,6 @@ module.exports = function (SocketUser) { | |||||||
|  |  | ||||||
| 		await user.isAdminOrSelf(socket.uid, data.uid); | 		await user.isAdminOrSelf(socket.uid, data.uid); | ||||||
|  |  | ||||||
| 		api.users.generateExport(socket, { type, ...data }); | 		api.users.generateExport(socket, { type, uid: data.uid }); | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user