app/roles/RestrictAnnotationAction.java
@Override
    public CompletionStage<Result> call(Http.Request req) {

        //Get roles of the user here.
        Integer profileId = SessionController.getCurrentUserId(req);
        List<String> profileRoles = new ArrayList<>();

        /* Replace check to ensure user role matches configuration.value()
            This will require the database structure set up
         */
        Optional<List<String>> roles = rolesRepository.getProfileRoles(profileId);
        if (roles.isPresent()) {
            profileRoles = roles.get();
        }

        // If so we are authorized, and the request should be called.
        if (profileRoles.contains(configuration.value()) || profileRoles.contains(GLOBAL_ADMIN_ROLE)) {
            return delegate.call(req);  // Allow the request proceed
        }

        // Otherwise we are not authorized, and the user should be redirected.
        return supplyAsync(() -> redirect("/profile").flashing("invalid",
                "You do not have permission to do this"));
    }
/**
     * When the method using the RestrictAnnotation tag is called, this will be run.
     * The user's role can be acquired here and then the restrict role checked against this.
     *
     * @param req The http request of the "tagged" method
     * @return Either a redirect call if not authorized, or the requested call if they are.
     */
When the method using the RestrictAnnotation tag is called, this will be run.
The user's role can be acquired here and then the restrict role checked against this.

@param req The http request of the "tagged" method
@return Either a redirect call if not authorized, or the requested call if they are.
When the method using the RestrictAnnotation tag is called this will be run . The user ' s role can be acquired here and then the restrict role checked against this . @param req The http request of the " tagged " method @return Either a redirect call if not authorized or the requested call if they are .
@Override
    public CompletionStage<Result> call(Http.Request req) {
        Integer profileId = SessionController.getCurrentUserId(req);
        List<String> profileRoles = new ArrayList<>();
        /* Replace check to ensure user role matches configuration.value()
            This will require the database structure set up
         */
        Optional<List<String>> roles = rolesRepository.getProfileRoles(profileId);
        if (roles.isPresent()) {
            profileRoles = roles.get();
        }
        if (profileRoles.contains(configuration.value()) || profileRoles.contains(GLOBAL_ADMIN_ROLE)) {
            return delegate.call(req);  
        }
        return supplyAsync(() -> redirect("/profile").flashing("invalid",
                "You do not have permission to do this"));
    }
@ Override public CompletionStage < Result > call ( Http . Request req ) { Integer profileId = SessionController . getCurrentUserId ( req ) ; List < String > profileRoles = new ArrayList < > ( ) ; /* Replace check to ensure user role matches configuration.value()
            This will require the database structure set up
         */ Optional < List < String > > roles = rolesRepository . getProfileRoles ( profileId ) ; if ( roles . isPresent ( ) ) { profileRoles = roles . get ( ) ; } if ( profileRoles . contains ( configuration . value ( ) ) || profileRoles . contains ( GLOBAL_ADMIN_ROLE ) ) { return delegate . call ( req ) ; } return supplyAsync ( ( ) -> redirect ( "/profile" ) . flashing ( "invalid" , "You do not have permission to do this" ) ) ; }
When the method using the RestrictAnnotation tag is called, this will be run.
When the method using the RestrictAnnotation tag is called this will be run .
//Get roles of the user here. // If so we are authorized, and the request should be called. // Allow the request proceed // Otherwise we are not authorized, and the user should be redirected.