Oth\’s Thoughts

OthAuth For CakePHP

Posted in CakePHP by othy on March 18, 2006

I’ve made an Authentication Component for CakePHP
you can download it in the snippet page at CakeForge

Comments are welcome.


13 Responses to 'OthAuth For CakePHP'

Subscribe to comments with RSS or TrackBack to 'OthAuth For CakePHP'.

  1. Jacek said,

    Is othAuth working with cake 1.0? I put $components=array(‘othAuth’); in AppCOntroller and I got error from a view

    Fatal error: Call to a member function on a non-object in … on line 55. This call javascript helper for loading javascript file. Maybe AppController is not good place for othAuth initializing in beforeFilter method?

  2. othy said,

    yea, the othAuth package is a component + helper
    $components are ( meant to be ) used in controllers,
    helpers are used i nthe views
    var $components = array(‘othAuth’); // component
    var $helpers = array(‘othAuth’);

  3. Jacek said,

    I know controllers and helpers.
    I put
    var $components=array(‘othAuth’);
    in AppController (isn’ this a controller?) and then I got error from view.
    The line with error in view calls javascript helper.
    link(‘script’); ?>
    Javascript helpers is added to helpers array in AppController.
    The error is only when I put othAuth into $components array in AppController. Why othAuth can not be in AppController?
    Where set beforeFilter method with othAuth init? In every controller?

  4. Jacek said,

    Sorry. It works fine. I just saved component with bad file name (othAuth.php, should be oth_auth.php).

  5. Damir Secki said,

    I’ve been looking for something like this for my new project.

    Good work!

  6. Sarah King said,

    Thanks for this. The system I’m working on has a group with 6814 users. This crashes othAuth because of the find() query. I’ve made these changes at around line 98.

    First, find the query and change the last parameter from a 2 to a 0

    then go down to line 101 and find

    if( empty($row) || $num_users != 1 )
    return -2;
    // new query
    $conditions = array(“{$this->group_model}.id” => $row[$this->group_model][‘id’]);
    $this->controller->{$this->user_model}->{$this->group_model}->unbindModel( array( “hasMany” => array( “{$this->user_model}”)));
    $perms = $this->controller->{$this->user_model}->{$this->group_model}->find($conditions, null, null, 1);
    $row[“{$this->group_model}”][“{$this->permission_model}”] = $perms[“{$this->permission_model}”];
    //back to the original code
    //save the session values

    I’ve no doubt that there is a more elegant way to do it but this works. The id for the group table is hard coded, that should probably be a parameter but the rest is good.

  7. Eduardo Pereira said,

    I’m using “$othAuth->sessionValid()” function to see if a session is valid in a view and I’m receiving the error message bellow:

    Undefined property: othAuthHelper::$hashkey in C:\Server\apache2triad\htdocs\opportoauth\app\views\helpers\oth_auth.php on line 42

    Could you tell me what am I doing wrong?


  8. Eduardo Pereira said,

    Another details about the same problem: I’m using “$othAuth->sessionValid()” function in default.thtml view.

    Thanks again.

  9. othy said,

    Is this in 1.2 ?
    I haven’t tested othAuth in 1.2, so I’m not quite sure

  10. Eduardo Pereira said,

    No, it’s not 1.2. Cakephp version is I also tested in version and received the same message.

  11. Sarah said,

    You’ve mentioned a new version that might be released soon. Need any help with it?

  12. othy said,

    Sarah: Well, there is a version in http://bakery.cakephp.org/articles/view/148
    but yeah help would be appreciated, as I have a list of things to be implemented and clean up and stuff.

  13. Mark said,

    First thanx for othAuth it’s a real timesaver for userauth and permissions!

    I get the Undefined property: OthAuthHelper::$hashkey when I turn on caching

    and exclude a part where you either get a login form or a greet (depends on whether you are logged in or not.) This is the relevant code snippet:

    	sessionValid()) {
    	} else {
    	}  ?>

    It must have something to do with the different way things are initialized when using cache (I think). Can you help me with finding a solution for this?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: