Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    •  
      CommentAuthorTalizmelf
     
    How to solve the problem that the controller's methods wich are non actions can still be accessed manually in the url.
    I mean there should be a way to protect non actions access via url.
    •  
      CommentAuthorbermi
     

    The convention is to _underscore_private_methods. camelCased methods can't be accessed via URL.

    •  
      CommentAuthorTalizmelf
     
    wat, wait... wich of the two can't be accessed via URL?? undersored or camelCased?
    I have written them both and sometimes it breaks with an error of missing template, other times it just get into index atcion without saying anything.

    I think it should trigger a 404 error or something.. :p

    Thanks...
    • CommentAuthorKaste
     

    some code

    /**
     * Sometimes it is useful to hide some actions, so they can't be accessed even though 
     * the dispatcher/router thinks the controller should invoke these methods.
     * 
     * Basically this is a convenience-function built upon the filter-chaining. Therefore 
     * call $this->hideActions(...) from the controllers constructor just like any other 
     * beforeFilter.
     * 
     * Examples:
     * 
     * $this->hideActions('forbid,invisible')
     * $this->hideActions(array('except'=>array('visible')) // all but 'visible'
     * $this->hideActions(array('only'  =>array('invisible')) 
     *
     * @param mixed $mixed  
     */
    function hideActions($mixed)
    {
        if (is_array($mixed) && (isset($mixed['only']) || isset($mixed['except']))){
            $condition = $mixed;            
        }else{
            $actions = Ak::toArray($mixed);
            $condition = array('only'=>$actions);
        }
        $this->beforeFilter(array('_forbidAction'=>$condition));
    }
    
    function _forbidAction()
    {
        //your code: throw an error or redirect 
    }
    

    hope its useful

    •  
      CommentAuthorTalizmelf
     
    Oh.. thanks.. This could work, but I would have to specify every action (function), even akelos own functions, because as I said, they still can be accessed via url.
    Even, the ones wich start with underscore... :(
    I'll keep thinking up!
    Thanks...
    •  
      CommentAuthorbermi
     

    Ok, you've found a serious bug that we have introduced without realizing. I've just added some unit tests and fix this issue on rev.1145

    Now _underscored_actions will be completely ignored by the router, so they will default to index. Regarding AkActionController actions you can't access them anymore.

    Thanks for coming with this up!

    •  
      CommentAuthorTalizmelf
     
    No man.. thanks you. but I suggest (better if it is optional) show a 404 error or some instead of showing index...
    The same with the actions attempted to be accessed wich do not exist..
    later...