mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	feat: sign load entities
This commit is contained in:
		
							parent
							
								
									2394ae2b9b
								
							
						
					
					
						commit
						06f9367dc3
					
				| @ -14,9 +14,18 @@ const addSignedFileUrlsToEntityService = async () => { | ||||
|   const decorator = (service) => ({ | ||||
|     async wrapResult(result, options) { | ||||
|       const wrappedResult = await service.wrapResult.call(this, result, options); | ||||
| 
 | ||||
|       // Load returns only the attribute of the entity, not the entity itself,
 | ||||
|       if (options.action === 'load') { | ||||
|         const entity = { [options.field]: result }; | ||||
|         const signedEntity = await signEntityMedia(entity, options.uid); | ||||
|         return signedEntity[options.field]; | ||||
|       } | ||||
| 
 | ||||
|       if (Array.isArray(wrappedResult)) { | ||||
|         return Promise.all(wrappedResult.map((entity) => signEntityMedia(entity, options.uid))); | ||||
|       } | ||||
| 
 | ||||
|       return signEntityMedia(wrappedResult, options.uid); | ||||
|     }, | ||||
|   }); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Marc-Roig
						Marc-Roig