Question

I am trying to implement CKEditor in my CakePHP app admin section with a third-party file manager (http://labs.corefive.com/2009/10/30/an-open-file-manager-for-ckeditor-3-0/).

Everything has been setup nicely, including uploading fotos, etc. However, I have one BIG issue I cant seem to figure out how to fix.

In the filemanager.config.php file there is the auth() function which prevent unauthorized use of the FileManager. I am not sure how to implement this function as to ONLY allow my app's administrator to use. In my user's table I use group_id to categorize users and the administrators group_id is 1.

I've thought about _SESSION, but I have not been able to create a solution.

/**
*   Check if user is authorized
*
*   @return boolean true is access granted, false if no access
*/
function auth() {
    // You can insert your own code over here to check if the user is authorized.
    // If you use a session variable, you've got to start the session first                                               
    session_start();
    if ($_SESSION['User.group_id'] == 1){
        return true;
    }else{
        return false;
    }
}

Thank you in advance for you help.

=====================================================================================

EDIT

I had the whole setup wrong

  1. I was using my CakePHP session as Database, I've changed it to php.
  2. And my $_SESSION code was wrong

I was able to fix it per the following:

function auth() {
    session_name("CAKEPHP");
    session_start();
    if(isset($_SESSION['Auth']['User']) )
    {
        if($_SESSION['Auth']['User']['group_id'] == 1)
        {
            return true;
        }
    }
    return false;
}

It works great as such.

====================================================================================

Était-ce utile?

La solution

The code you show is from fceditor? If you set up auth in CakePHP correctly and have not modified the default session key your user data will be in $_SESSIOn['Auth']['User'].

In CakePHP do not use $_SESSION directly, use the Session component.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top