Re: Auth problem with '/' and "You are not authorized to access that location."
Url '/' points by default routes to PagesController::display(), so you should call either a) in PagesController::beforeFilter(): parent::beforeFilter(); $this->Auth->allow('display'); or b) in AppController::beforeFilter(): if ($this->name == 'Pages') { $this->Auth->allow('display'); } Your usage $this->Auth->allow('/') is wrong, this is not valid argument. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Containable grabbing too much data
Yeah I guess we have the same problem, and I have spent a good few hour trying to fix this with no avail. Lets hope its a bug and an official comes and sees this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Containable grabbing too much data
Thanks for posting that. I also have an afterFind callback in the model that is giving me too much data, so that must be the problem. I'm kinda glad it's not because I wasn't understanding 'contain' behaviour. Unfortunately the afterFind contains some logic that I can't do without, so I'll have to stick with a custom query solution I think. On Jun 28, 10:02 am, Miles J wrote: > I found the problem, but cannot fix it. Its my afterFind() method for > my Article model. > > /** > * Executed after a find() call > */ > function afterFind($results) { > if (!empty($results)) { > foreach ($results as &$result) { > if (is_array($result) && > !empty($result['Article']['id'])) { > $result['Article']['favorites'] = > $this->Favorites->find('count', > array( > 'conditions' => > array('Favorites.article_id' => $result > ['Article']['id']), > 'contain' => false, > 'recursive' => -1 > )); > > $result['Article']['comments'] = > $this->Comments->find('count', > array( > 'conditions' => > array('Comments.item_id' => $result['Article'] > ['id'], 'Comments.status' => 'approved'), > 'contain' => false, > 'recursive' => -1 > )); > } > } > } > > return $results; > } > > Even when I disable contain and recursive, it still grabs all the > extra data. BUT WHEN I remove the after find, the correct data is > returned. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Containable grabbing too much data
I found the problem, but cannot fix it. Its my afterFind() method for my Article model. /** * Executed after a find() call */ function afterFind($results) { if (!empty($results)) { foreach ($results as &$result) { if (is_array($result) && !empty($result['Article']['id'])) { $result['Article']['favorites'] = $this->Favorites->find('count', array( 'conditions' => array('Favorites.article_id' => $result ['Article']['id']), 'contain' => false, 'recursive' => -1 )); $result['Article']['comments'] = $this->Comments->find('count', array( 'conditions' => array('Comments.item_id' => $result['Article'] ['id'], 'Comments.status' => 'approved'), 'contain' => false, 'recursive' => -1 )); } } } return $results; } Even when I disable contain and recursive, it still grabs all the extra data. BUT WHEN I remove the after find, the correct data is returned. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Auth problem with '/' and "You are not authorized to access that location."
Hi, I've got a setup where i've got a login action at /users/login. If you go directly to that controller, action there is no error message wereas if you goto '/' as in the site address with no controller or action and then follow the routes i've got setup for '/' to /users/login you get this message. I've tried putting this into the beforeFilter $this->Auth->allow( '/' ); but doesn't seem to help. Thanks, Tim. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Auth->authenticate in beforeFilter causes Auth issues
You can set the salt to an empty strung, too. Regards 2009/6/27 Justin Poliey > > That's where I got the information I'm using now. The problem is if I > just change the hash function with Security::setHash, Cake will still > apply the salt before it hashes the passwords, so the hashes will > still be incompatible. > > Thanks > Justin > > On Jun 27, 7:06 am, John Andersen wrote: > > I understand that you are using MD5 instead of SHA1 in your user > > model! > > > > If that is the final decision, then why don't you just tell CakePHP to > > use MD5 as default and as shown in the example at: > > > > http://book.cakephp.org/view/566/Change-Hash-Function > > > > Maybe that would help you! > > Enjoy, > >John > > > > On Jun 27, 10:37 am, Justin Poliey wrote: > > > > > Right now I'm using Cake's Auth component to build a simple user > > > system. Pastes of the files in their entirety are availablehttp:// > gist.github.com/136935forreference. > > > > > The problem is that when I call: $this->Auth->authenticate = > > > ClassRegistry::init('User'), login.ctp always shows "Login failed. > > > Invalid username or password." even when I haven't submitted anything. > > > If I uncomment that line (line 10, users_controller.php) the message > > > is suppressed but the login logic doesn't work, because it needs the > > > hashedPasswords function in the User model to get the proper password > > > hash. We need to use plain md5 hashes instead of Cake's regular hash > > > because before converting to Cake all of our users just had plain md5 > > > hashed passwords. > > > > > The strangest thing is that this happened before, and was solved by > > > getting rid of all the relevant code, and then completely rewriting > > > it. After the rewrite, it worked for a while, and then I must have > > > done something to break it again. Can anyone see what is wrong? Am I > > > doing something dumb and just not realizing it? > > > > > Thanks for any help. > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Insert values question
Originally I had my ID's set as INT(11) but am going to try using the UUID CHAR(36) for the ID value So I have my old sql INSERT INTO `countries` (`id`, `iso`, `name`, `region`, `flag`) VALUES (1, 'AD', 'Andorra', 'Europe', 'ad'), (2, 'AE', 'United Arab Emirates', 'Middle East', 'flags/ae.gif'), (3, 'AF', 'Afghanistan', 'Asia', ''), (4, 'AG', 'Antigua and Barbuda', 'Central America and the Caribbean', ''), (5, 'AI', 'Anguilla', 'Central America and the Caribbean', ''), (6, 'AL', 'Albania', 'Europe', ''), ...so on So does anyone know how to insert this into the database now where I will delete 1,2,3,manually but how to have mySQL generate the UUID? Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
ACL question
I am setting up a new app using ACL. I am using Role , user can only have 1 role so User model has: var $hasOne = array( 'Role' => array( 'className' => 'Role', 'foreignKey' => 'user_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '' ) ); function parentNode() { if (!$this->id && empty($this->data)) { return null; } $data = $this->data; if (empty($this->data)) { $data = $this->read(); } if (!$data['User']['role_id']) { return null; } else { return array('Role' => array('id' => $data['User']['role_id'])); } } but when adding users with different roles ACOS looks wrong: 1, NULL, 'Role', 1, NULL, 1, 10), (2, NULL, 'Role', 2, NULL, 11, 18), (3, NULL, 'Role', 3, NULL, 19, 22), (4, NULL, 'Role', 4, NULL, 23, 24), (5, NULL, 'Role', 5, NULL, 25, 26), (6, 2, 'User', 4, NULL, 16, 17), <- foreign key is wrong (7, 1, 'User', 4, NULL, 8, 9); <- foreign key is wrong the foreign keys should be differet no? Where did I go wrong here? Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Auth->authenticate in beforeFilter causes Auth issues
That's where I got the information I'm using now. The problem is if I just change the hash function with Security::setHash, Cake will still apply the salt before it hashes the passwords, so the hashes will still be incompatible. Thanks Justin On Jun 27, 7:06 am, John Andersen wrote: > I understand that you are using MD5 instead of SHA1 in your user > model! > > If that is the final decision, then why don't you just tell CakePHP to > use MD5 as default and as shown in the example at: > > http://book.cakephp.org/view/566/Change-Hash-Function > > Maybe that would help you! > Enjoy, > John > > On Jun 27, 10:37 am, Justin Poliey wrote: > > > Right now I'm using Cake's Auth component to build a simple user > > system. Pastes of the files in their entirety are > > availablehttp://gist.github.com/136935forreference. > > > The problem is that when I call: $this->Auth->authenticate = > > ClassRegistry::init('User'), login.ctp always shows "Login failed. > > Invalid username or password." even when I haven't submitted anything. > > If I uncomment that line (line 10, users_controller.php) the message > > is suppressed but the login logic doesn't work, because it needs the > > hashedPasswords function in the User model to get the proper password > > hash. We need to use plain md5 hashes instead of Cake's regular hash > > because before converting to Cake all of our users just had plain md5 > > hashed passwords. > > > The strangest thing is that this happened before, and was solved by > > getting rid of all the relevant code, and then completely rewriting > > it. After the rewrite, it worked for a while, and then I must have > > done something to break it again. Can anyone see what is wrong? Am I > > doing something dumb and just not realizing it? > > > Thanks for any help. > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Two models how to access in one controller
Thanks its working now On Jun 27, 2:19 pm, Vijay Kumbhar wrote: > Hello rajasekaran, > > Please check the model names in the $uses. > You have made a mistake in the model name of "Employees" it has to be > "Employee". > If you have any other error please post it here for more help. > > On Fri, Jun 26, 2009 at 9:52 PM, harish rajasekaran < > > > > harish.rsn.av...@gmail.com> wrote: > > > Hi i am using two model and i want to access that models in one > > controller how can i use please help see my below code > > > class EmployeesController extends AppController { > > var $name = 'Employees'; > > var $helpers = array('Html', 'Form'); > > function register() > > { //code > > > if (!empty($this->data)) { > > > $storeVal = $this->data['Employee']['email_id']; > > $checkQuery = $this->Employee->find('all', array('conditions' => > > array('Employee.email_id' => $storeVal))); > > //echo sizeof($checkQuery); > > if(sizeof($checkQuery)==0){ > > $this->Employee->create(); > > > if ($this->Employee->save($this->data)) { > > $this->Employeelogin->create(); > > if($this->Employeelogin->save($this->data)) > > $this->Session->setFlash('The Task has been saved'); > > $this->redirect(array('action'=>'index'), null, true); > > } else { > > $this->Session->setFlash('Task not saved. Try again.'); > > } > > } > > else > > $this->Session->setFlash('E-mail id already exists'); > > } > > > } > > } > > > if i use var $uses = array('Employees','Employeelogin'); it gives > > error please help hoe to solve this problem > > -- > Thanks & Regards, > Vijayk. > > "You Bring the Dreams, We'll Bring the Means" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Auth->authenticate in beforeFilter causes Auth issues
I understand that you are using MD5 instead of SHA1 in your user model! If that is the final decision, then why don't you just tell CakePHP to use MD5 as default and as shown in the example at: http://book.cakephp.org/view/566/Change-Hash-Function Maybe that would help you! Enjoy, John On Jun 27, 10:37 am, Justin Poliey wrote: > Right now I'm using Cake's Auth component to build a simple user > system. Pastes of the files in their entirety are > availablehttp://gist.github.com/136935for reference. > > The problem is that when I call: $this->Auth->authenticate = > ClassRegistry::init('User'), login.ctp always shows "Login failed. > Invalid username or password." even when I haven't submitted anything. > If I uncomment that line (line 10, users_controller.php) the message > is suppressed but the login logic doesn't work, because it needs the > hashedPasswords function in the User model to get the proper password > hash. We need to use plain md5 hashes instead of Cake's regular hash > because before converting to Cake all of our users just had plain md5 > hashed passwords. > > The strangest thing is that this happened before, and was solved by > getting rid of all the relevant code, and then completely rewriting > it. After the rewrite, it worked for a while, and then I must have > done something to break it again. Can anyone see what is wrong? Am I > doing something dumb and just not realizing it? > > Thanks for any help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Two models how to access in one controller
Hello rajasekaran, Please check the model names in the $uses. You have made a mistake in the model name of "Employees" it has to be "Employee". If you have any other error please post it here for more help. On Fri, Jun 26, 2009 at 9:52 PM, harish rajasekaran < harish.rsn.av...@gmail.com> wrote: > > Hi i am using two model and i want to access that models in one > controller how can i use please help see my below code > > class EmployeesController extends AppController { > var $name = 'Employees'; > var $helpers = array('Html', 'Form'); > function register() > { //code > > if (!empty($this->data)) { > > $storeVal = $this->data['Employee']['email_id']; > $checkQuery = $this->Employee->find('all', array('conditions' => > array('Employee.email_id' => $storeVal))); > //echo sizeof($checkQuery); > if(sizeof($checkQuery)==0){ > $this->Employee->create(); > > if ($this->Employee->save($this->data)) { > $this->Employeelogin->create(); > if($this->Employeelogin->save($this->data)) > $this->Session->setFlash('The Task has been saved'); > $this->redirect(array('action'=>'index'), null, true); > } else { > $this->Session->setFlash('Task not saved. Try again.'); > } > } > else > $this->Session->setFlash('E-mail id already exists'); > } > > } > } > > > > if i use var $uses = array('Employees','Employeelogin'); it gives > error please help hoe to solve this problem > > > > -- Thanks & Regards, Vijayk. "You Bring the Dreams, We'll Bring the Means" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Need help with my TidyHelper
Hello. i have this little helper that works ok with standard HTML pages but it screws up all my PDF reports class TidyHelper extends AppHelper { function __construct() { ob_start(); } function __destruct() { $output = ob_get_clean(); if(class_exists("Tidy")) { //here's the tidy code } echo $output; } } what can i do to disable this helper when the layout = "PDF"? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
jsmin helper can not work with Email component.
In Email::__renderTemplate() $content = $View->element('email' . DS . 'text' . DS . $this->template, > array('content' => $content), true); > And below is View::element definition: > function element($name, $params = array(), $loadHelpers = false) So if the loadHelper was set true, the 'afterRender' callback function will be called: if ($loadHelpers === true) { > $this->_triggerHelpers('afterRender'); > } And in Jsmin::afterRender: function afterRender(){ //. *$view =& ClassRegistry::getObject('view');* $view->addScript($out); return true; } $view =& ClassRegistry::getObject('view'); //the view is null. I just don't know why the view object couldn't be got here?* * -- Thanks Joshua --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: loginRedirect issue
It seem the $this->Auth->autoRedirect didn't function. On Sat, Jun 27, 2009 at 3:10 AM, PHPScriptKiddy wrote: > > Hey guys, I'm working on my first ACL setup, but am having some > trouble with the login. I have been modelling everything after the ACL > tutorial in the cakephp cookbook. Ok here's my issue... > > Within the app_controller i have the following > > function beforeFilter() { >//Configure AclComponent >//$this->Acl->Aco->create(array('parent_id' => null, 'alias' => > 'controllers')); >//$this->Acl->Aco->save(); > >//Configure AuthComponent >$this->Auth->actionPath = 'controllers/'; >$this->Auth->authorize = 'actions'; >$this->Auth->logoutRedirect = array('controller' => 'users', > 'action' > => 'login'); >$this->Auth->loginRedirect = array('controller' => 'users', 'action' > => 'index'); >$this->Auth->allowedActions = array('display'); >$this->Auth->loginAction = array('controller' => 'users', 'action' > => > 'login'); > } > > However, whenever I login instead of being directed to 'users/index' I > am dumped back to the login screen with an authError, but I am > actually logged in. Now if I try logging in again, everything works > properly. I assume that it is trying to direct me to 'users/index' > before actually logging me in, but I can't find anywhere to check > this. > > Does anyone have any useful tips? > > Thanks in advance! > > > > -- Thanks Joshua --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Auth->authenticate in beforeFilter causes Auth issues
Right now I'm using Cake's Auth component to build a simple user system. Pastes of the files in their entirety are available http://gist.github.com/136935 for reference. The problem is that when I call: $this->Auth->authenticate = ClassRegistry::init('User'), login.ctp always shows "Login failed. Invalid username or password." even when I haven't submitted anything. If I uncomment that line (line 10, users_controller.php) the message is suppressed but the login logic doesn't work, because it needs the hashedPasswords function in the User model to get the proper password hash. The strangest thing is that this happened before, and was solved by getting rid of all the relevant code, and then completely rewriting it. After the rewrite, it worked for a while, and then I must have done something to break it again. Can anyone see what is wrong? Am I doing something dumb and just not realizing it? Thanks for any help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Auth->authenticate in beforeFilter causes Auth issues
Right now I'm using Cake's Auth component to build a simple user system. Pastes of the files in their entirety are available http://gist.github.com/136935 for reference. The problem is that when I call: $this->Auth->authenticate = ClassRegistry::init('User'), login.ctp always shows "Login failed. Invalid username or password." even when I haven't submitted anything. If I uncomment that line (line 10, users_controller.php) the message is suppressed but the login logic doesn't work, because it needs the hashedPasswords function in the User model to get the proper password hash. We need to use plain md5 hashes instead of Cake's regular hash because before converting to Cake all of our users just had plain md5 hashed passwords. The strangest thing is that this happened before, and was solved by getting rid of all the relevant code, and then completely rewriting it. After the rewrite, it worked for a while, and then I must have done something to break it again. Can anyone see what is wrong? Am I doing something dumb and just not realizing it? Thanks for any help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
loginRedirect issue
Hey guys, I'm working on my first ACL setup, but am having some trouble with the login. I have been modelling everything after the ACL tutorial in the cakephp cookbook. Ok here's my issue... Within the app_controller i have the following function beforeFilter() { //Configure AclComponent //$this->Acl->Aco->create(array('parent_id' => null, 'alias' => 'controllers')); //$this->Acl->Aco->save(); //Configure AuthComponent $this->Auth->actionPath = 'controllers/'; $this->Auth->authorize = 'actions'; $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login'); $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'index'); $this->Auth->allowedActions = array('display'); $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); } However, whenever I login instead of being directed to 'users/index' I am dumped back to the login screen with an authError, but I am actually logged in. Now if I try logging in again, everything works properly. I assume that it is trying to direct me to 'users/index' before actually logging me in, but I can't find anywhere to check this. Does anyone have any useful tips? Thanks in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---