Browse Source
			
			
			Bugfix/fix public page (#2065)
			
				* Check for user in request because of public page
* Update changelog
			
			
				pull/2066/head
			
			
		 
		
			
				
					
						 Thomas Kaul
					
					2 years ago
						Thomas Kaul
					
					2 years ago
					
						
							committed by
							
								 GitHub
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 4AEE18F83AFDEB23
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
29 additions and 
14 deletions
			 
			
		 
		
			
				- 
					
					
					 
					CHANGELOG.md
				
- 
					
					
					 
					apps/api/src/services/impersonation/impersonation.service.ts
				
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | 
			
		
	
		
			
				
					|  |  |  | ### Fixed | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | - Fixed an issue with the value nullification related to the investment streaks | 
			
		
	
		
			
				
					|  |  |  | - Fixed an issue in the public page related to the impersonation service | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | ## 1.278.0 - 2023-06-09 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -12,22 +12,36 @@ export class ImpersonationService { | 
			
		
	
		
			
				
					|  |  |  |   ) {} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   public async validateImpersonationId(aId = '') { | 
			
		
	
		
			
				
					|  |  |  |     const accessObject = await this.prismaService.access.findFirst({ | 
			
		
	
		
			
				
					|  |  |  |       where: { | 
			
		
	
		
			
				
					|  |  |  |         GranteeUser: { id: this.request.user.id }, | 
			
		
	
		
			
				
					|  |  |  |         id: aId | 
			
		
	
		
			
				
					|  |  |  |     if (this.request.user) { | 
			
		
	
		
			
				
					|  |  |  |       const accessObject = await this.prismaService.access.findFirst({ | 
			
		
	
		
			
				
					|  |  |  |         where: { | 
			
		
	
		
			
				
					|  |  |  |           GranteeUser: { id: this.request.user.id }, | 
			
		
	
		
			
				
					|  |  |  |           id: aId | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |       }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |       if (accessObject?.userId) { | 
			
		
	
		
			
				
					|  |  |  |         return accessObject.userId; | 
			
		
	
		
			
				
					|  |  |  |       } else if ( | 
			
		
	
		
			
				
					|  |  |  |         hasPermission( | 
			
		
	
		
			
				
					|  |  |  |           this.request.user.permissions, | 
			
		
	
		
			
				
					|  |  |  |           permissions.impersonateAllUsers | 
			
		
	
		
			
				
					|  |  |  |         ) | 
			
		
	
		
			
				
					|  |  |  |       ) { | 
			
		
	
		
			
				
					|  |  |  |         return aId; | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  |     } else { | 
			
		
	
		
			
				
					|  |  |  |       // Public access
 | 
			
		
	
		
			
				
					|  |  |  |       const accessObject = await this.prismaService.access.findFirst({ | 
			
		
	
		
			
				
					|  |  |  |         where: { | 
			
		
	
		
			
				
					|  |  |  |           GranteeUser: null, | 
			
		
	
		
			
				
					|  |  |  |           User: { id: aId } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |       }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     if (accessObject?.userId) { | 
			
		
	
		
			
				
					|  |  |  |       return accessObject?.userId; | 
			
		
	
		
			
				
					|  |  |  |     } else if ( | 
			
		
	
		
			
				
					|  |  |  |       hasPermission( | 
			
		
	
		
			
				
					|  |  |  |         this.request.user.permissions, | 
			
		
	
		
			
				
					|  |  |  |         permissions.impersonateAllUsers | 
			
		
	
		
			
				
					|  |  |  |       ) | 
			
		
	
		
			
				
					|  |  |  |     ) { | 
			
		
	
		
			
				
					|  |  |  |       return aId; | 
			
		
	
		
			
				
					|  |  |  |       if (accessObject?.userId) { | 
			
		
	
		
			
				
					|  |  |  |         return accessObject.userId; | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     return null; | 
			
		
	
	
		
			
				
					|  |  | 
 |