othAuth 0.5.4
This is mainly a bug fix release.
- fixed a bug related to Y-m-d H:i:s
- Fixed a bug in loginAttempts reported by PatDaMilla
- Added support for parameters sent via url in a traditional way, mainly for redirects, thanks to Ritesh.
What else I’m not sure but we’re going towards a more stable system.
the nao mode is broken at the moment, I’ll fix it when I’ll have time to write docs for it.
There’s a bug that prevents othAuth from recovering a session from the cookie data.
$pos = strpos($r.”/”,$this->controller->action.”/”);
if($pos === 0)……
strpos() returns boolean false so that if will never work
I changed it to:
if(strpos($r.”/”,$this->controller->action.”/”)){….
no.. my bad.. that wasn’t the actual problem, that was ok!
The problem was that check() only reads the cookie with _readCookie() if _validRestrictions() returns true, and it only returns true when you access a restricted page. Wich means that the session data isn’t written until that time, so if i need the logged in user’s data or i use $othAuth->sessionValid() in the view… you get the point!
I moved _readCookie() out of that if and now everything is ok.
Hmm you get a point.
While am at it..
You should do this:
if(!class_exists(’Sanitize’)){
uses(’Sanitize’);
}
Because uses() only does a require_once() and that’s slower than first checking class_exists(). See the comments here http://php.net/require_once and also CakePHP’s core is using this method.
I don’t really understand why they don’t change uses() to do this by default.
Also, you’re loading both Sanitize and Inflector twice in othAuth.. You should only do it once for each of them..
Actually.. the Inflector is used all over CakePHP so you can skip it as it is already loaded..
And about loadModel().. especially for the User Model..
You might want to use an instance. Look at this little article http://www.thinkingphp.org/2007/01/22/how-to-properly-create-a-model-instance-manually/
Hi gribelu,
Bare in mind that othAuth is compatible with 1.1 and 1.2
If you have improvements to core code, please submit tickets to https://trac.cakephp.org/newticket along with patches.
Inflector is used all over the core code yes, but it doesn’t mean it’s available. specially not in 1.1.
Sanitize is not loaded twice. it’s used in the modes’ login functions. You can’t have two modes. so it’s fine.
Those classes are singletons.
if (ClassRegistry::isKeySet($this->user_model)) {
$UserModel =& ClassRegistry::getObject($this->user_model);
}
else {
loadModel($this->user_model);
$UserModel =& new $this->user_model;
}
This code is fine.
I’ve read felix’ stuff. He’s basically doing the same thing and adding the object to the class registry for further use. this is not needed in othAuth because the user model is only used once.
Thanks for the comment.
hello i have a problem with othauth :S
Notice: Only variables should be assigned by reference in C:\AppServ\www\cake\maractivo\controllers\components\oth_auth.php on line 301
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\cake\maractivo\controllers\components\oth_auth.php:301) in C:\AppServ\www\cake\cake\libs\controller\controller.php on line 446
i’m using lastest stable of cakephp 1.1.14.4797
with php.4.4.5
any one can help me :S
Hi I am getting the same error as stefano…in cake 1.2 — 1.2.0.5165alpha.
I guess ti is something simple we are both doign wrong?
Luke
Thank you very much for providing the othAuth component and it’s helper. I really enjoy using it and so does everyone else out there! Please keep up the good work and keep developing.
Thanks very much for the OthAuth component, helper and accompanying docs, very handy indeed.
I made a few tweaks to get the nao mode working and support a class based hashing callback.
I can’t post to the Bakery yet as I’m still waiting for my registration to come through but here’s a little bit of diff for you in the mean-time if you are, or anyone else is, interested: http://www.changelinginteractive.com/files/oth_auth.diff
I’ve tested my changes and they all work fine for php 5 but the refs may need looking at for php 4.
Thanks again, Martin