capella-collab-manager icon indicating copy to clipboard operation
capella-collab-manager copied to clipboard

Create and apply verification classes for admin and project manager

Open dominik003 opened this issue 1 year ago • 0 comments

Right now, we have single RoleVerification and ProjectRoleVerification classes. However, most often we have to use the RoleVerification like this:

fastapi.Depends(
            auth_injectables.RoleVerification(
                required_role=users_model.Role.ADMIN
            )
        )

and the ProjectRoleVerificationlike this:

fastapi.Depends(
            auth_injectables.ProjectRoleVerification(
                required_role=ProjectUserRole.MANAGER
            )
        )

This approach has the disadvantage that we always have to import the user and project users model, needed to provide the required_role argument. Here I would suggest to create two new injectables AdminRoleVerification and ManagerProjectRoleVerification that simply use the abstract RoleVerification and ProjectRoleVerification with the predefined role (both injectables should still have an optional field verify: bool = true).

dominik003 avatar Jun 05 '23 14:06 dominik003