Added a new endpoint that returns a users permissions as objects sorted into two arrays
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/pr Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/pr Build is passing
				
			ref #93
This commit is contained in:
		@@ -70,6 +70,7 @@ export class ResponseUser extends ResponsePrincipal {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The user's permissions.
 | 
			
		||||
     * Directly granted or inherited converted to their string form and deduplicated.
 | 
			
		||||
     */
 | 
			
		||||
    @IsArray()
 | 
			
		||||
    @IsOptional()
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										40
									
								
								src/models/responses/ResponseUserPermissions.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/models/responses/ResponseUserPermissions.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
import {
 | 
			
		||||
    IsArray,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    IsOptional
 | 
			
		||||
} from "class-validator";
 | 
			
		||||
import { User } from '../entities/User';
 | 
			
		||||
import { ResponsePermission } from './ResponsePermission';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Defines the user permission response (get /api/users/:id/permissions).
 | 
			
		||||
*/
 | 
			
		||||
export class ResponseUserPermissions {
 | 
			
		||||
    /**
 | 
			
		||||
     * The permissions directly granted to the user.
 | 
			
		||||
     */
 | 
			
		||||
    @IsArray()
 | 
			
		||||
    @IsOptional()
 | 
			
		||||
    directlyGranted: ResponsePermission[] = new Array<ResponsePermission>();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The permissions directly inherited the user.
 | 
			
		||||
     */
 | 
			
		||||
    @IsArray()
 | 
			
		||||
    @IsOptional()
 | 
			
		||||
    inherited: ResponsePermission[] = new Array<ResponsePermission>();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a ResponseUserPermissions object from a user.
 | 
			
		||||
     * @param user The user the response shall be build for.
 | 
			
		||||
     */
 | 
			
		||||
    public constructor(user: User) {
 | 
			
		||||
        for (let permission of user.permissions) {
 | 
			
		||||
            this.directlyGranted.push(permission.toResponse());
 | 
			
		||||
        }
 | 
			
		||||
        for (let permission of user.inheritedPermissions) {
 | 
			
		||||
            this.inherited.push(permission.toResponse());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user