Re: Creating a login screen
take a look at: http://book.cakephp.org/view/172/Authentication On Nov 23, 3:18 pm, Dewayne Pinion wrote: > Hey All, > I am wanting to create a login page for a cake app that allows a user to add > products/pictures to their pages. I have the app worked out, but not sure on > how to create the login. Any links or advice someone could give me to get me > started? > > Thanks -- You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-...@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=.
Re: render shared view file
amit, overriding render() function sounds just right, didn't tought of that.. :) thanks for the idea! walther, thanks. saw that at the very start of my research of this problem, but as i said in the first post, sounds like an overkill to me. IMO, what i need should be as easy as setting some variable in controller. but i'll go with amit's proposal if it works (and i don't see why it wouldn't work), it's simple enough. On Nov 23, 6:40 am, Walther wrote: > This:http://bakery.cakephp.org/articles/view/generating-automatized-json-a... > > is exactly what you are looking for. > > On Nov 18, 2:13 pm, ddaffy wrote: > > > > > hi! > > > i'm using Router::parseExtensions('json') to be able to request data > > delivered in json format, and i've been wondering if there's a way to > > change view file that will be used to render data? > > > if action test from Examples controller ( /examples/test ) is > > requested, default view (app/views/examples/test.ctp) is rendered with > > default layout (app/views/layouts/default.ctp). > > > if /examples/test.json is requested app/views/examples/json/test.ctp > > is rendered with app/views/layouts/json/default.ctp layout. > > > because i use unified way for passing variables to view, i don't need > > every action to have different view for json extension (app/views/ > > examples/json/test1.ctp, app/views/examples/json/test2.ctp...), and i > > would like to use e.g. app/views/shared/json.ctp. i know how to > > achieve this for single action, but i need a way to do this globally > > (in AppController). > > > what i tried: > > > funciton beforeRender() { > > if ($this->RequestHandler->ext == 'json') { > > $this->viewPath = 'shared'; > > } > > > } > > > results in rendering app/views/shared/.ctp > > > funciton beforeRender() { > > if ($this->RequestHandler->ext == 'json') { > > $this->render('/shared/json'); > > // or: $this->render('shared/json'); > > // or: $this->render(null, null, '/shared/json'); > > // or variations.. > > } > > > } > > > result is empty. > > > also i saw solution with creating new view class that will override > > render function and customising it, but it sounds like overkill to > > me.. > > > ideal solution in addition to setting $viewPath ($this->viewPath = > > 'shared') would be to change name of view file that will be requested > > for rendering, but haven't found a way to do that. > > > any ideas would be appreciated. > > thanks. :) -- You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-...@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=.
Re: render shared view file
sure, i can do that, and it works really fine. but problem is, if you read first post, i need a way to do this on all actions, in AppController or SomeController, depending on extension (.json in this case). On Nov 22, 4:14 pm, Dave wrote: > You just call it right from the action > > > > On Sun, Nov 22, 2009 at 9:39 AM, ddaffy wrote: > > thanks for replies guys. :) > > > i came to a conclusion that i can't use render() function for this > > purpose. reason is there are three callbacks i could place this call > > in: > > - AppController::beforeFilter() - won't work because it's called > > before action > > - AppController::beforeRender() - won't work because it'll go into > > infinite loop (render() calls beforeRender()) > > - AppController::afterFilter() - won't work because rendering is > > already done > > > only thing i see, that would solve this, is that some variable which > > would specify name of view file is added to controller (like $layout), > > and used in render() action to determine view file. if some other > > solution doesn't come up, i'll post feature request. maybe i get > > lucky. :) > > > cheers > > > On Nov 19, 8:25 am, David Roda wrote: > > > Last response I promise! > > > > I read the whole post this time... If you want to change the view that is > > > rendered for an action you can manually call $this->render . Also the > > > target action can be tested for with $this->action if you need to test > > for > > > specific cases. > > > > On Thu, Nov 19, 2009 at 2:22 AM, David Roda > > wrote: > > > > I'm sorry its late... I didn't even read your post... please ignore my > > > > reply! =( > > > > > On Thu, Nov 19, 2009 at 2:21 AM, David Roda > > wrote: > > > > >> I think you can use the RequestHandler component for this. > > > >>http://book.cakephp.org/view/174/Request-Handling > > > > >> On Wed, Nov 18, 2009 at 10:31 PM, Dr. Loboto > > wrote: > > > > >>> There is a hack to render view from other folder: $this->render > > > >>> ('..'.DS.'shared'.DS.'json'); > > > > >>> On Nov 18, 6:13 pm, ddaffy wrote: > > > >>> > hi! > > > > >>> > i'm using Router::parseExtensions('json') to be able to request > > data > > > >>> > delivered in json format, and i've been wondering if there's a way > > to > > > >>> > change view file that will be used to render data? > > > > >>> > if action test from Examples controller ( /examples/test ) is > > > >>> > requested, default view (app/views/examples/test.ctp) is rendered > > with > > > >>> > default layout (app/views/layouts/default.ctp). > > > > >>> > if /examples/test.json is requested > > app/views/examples/json/test.ctp > > > >>> > is rendered with app/views/layouts/json/default.ctp layout. > > > > >>> > because i use unified way for passing variables to view, i don't > > need > > > >>> > every action to have different view for json extension (app/views/ > > > >>> > examples/json/test1.ctp, app/views/examples/json/test2.ctp...), and > > i > > > >>> > would like to use e.g. app/views/shared/json.ctp. i know how to > > > >>> > achieve this for single action, but i need a way to do this > > globally > > > >>> > (in AppController). > > > > >>> > what i tried: > > > > >>> > funciton beforeRender() { > > > >>> > if ($this->RequestHandler->ext == 'json') { > > > >>> > $this->viewPath = 'shared'; > > > >>> > } > > > > >>> > } > > > > >>> > results in rendering app/views/shared/.ctp > > > > >>> > funciton beforeRender() { > > > >>> > if ($this->RequestHandler->ext == 'json') { > > > >>> > $this->render('/shared/json'); > > > >>> > // or: $this->render('shared/json'); > > > >>> > // or: $this->render(null, null, '/shared/json'); > > > >>> > // or variations.. > > >
Re: render shared view file
thanks for replies guys. :) i came to a conclusion that i can't use render() function for this purpose. reason is there are three callbacks i could place this call in: - AppController::beforeFilter() - won't work because it's called before action - AppController::beforeRender() - won't work because it'll go into infinite loop (render() calls beforeRender()) - AppController::afterFilter() - won't work because rendering is already done only thing i see, that would solve this, is that some variable which would specify name of view file is added to controller (like $layout), and used in render() action to determine view file. if some other solution doesn't come up, i'll post feature request. maybe i get lucky. :) cheers On Nov 19, 8:25 am, David Roda wrote: > Last response I promise! > > I read the whole post this time... If you want to change the view that is > rendered for an action you can manually call $this->render . Also the > target action can be tested for with $this->action if you need to test for > specific cases. > > > > On Thu, Nov 19, 2009 at 2:22 AM, David Roda wrote: > > I'm sorry its late... I didn't even read your post... please ignore my > > reply! =( > > > On Thu, Nov 19, 2009 at 2:21 AM, David Roda wrote: > > >> I think you can use the RequestHandler component for this. > >>http://book.cakephp.org/view/174/Request-Handling > > >> On Wed, Nov 18, 2009 at 10:31 PM, Dr. Loboto wrote: > > >>> There is a hack to render view from other folder: $this->render > >>> ('..'.DS.'shared'.DS.'json'); > > >>> On Nov 18, 6:13 pm, ddaffy wrote: > >>> > hi! > > >>> > i'm using Router::parseExtensions('json') to be able to request data > >>> > delivered in json format, and i've been wondering if there's a way to > >>> > change view file that will be used to render data? > > >>> > if action test from Examples controller ( /examples/test ) is > >>> > requested, default view (app/views/examples/test.ctp) is rendered with > >>> > default layout (app/views/layouts/default.ctp). > > >>> > if /examples/test.json is requested app/views/examples/json/test.ctp > >>> > is rendered with app/views/layouts/json/default.ctp layout. > > >>> > because i use unified way for passing variables to view, i don't need > >>> > every action to have different view for json extension (app/views/ > >>> > examples/json/test1.ctp, app/views/examples/json/test2.ctp...), and i > >>> > would like to use e.g. app/views/shared/json.ctp. i know how to > >>> > achieve this for single action, but i need a way to do this globally > >>> > (in AppController). > > >>> > what i tried: > > >>> > funciton beforeRender() { > >>> > if ($this->RequestHandler->ext == 'json') { > >>> > $this->viewPath = 'shared'; > >>> > } > > >>> > } > > >>> > results in rendering app/views/shared/.ctp > > >>> > funciton beforeRender() { > >>> > if ($this->RequestHandler->ext == 'json') { > >>> > $this->render('/shared/json'); > >>> > // or: $this->render('shared/json'); > >>> > // or: $this->render(null, null, '/shared/json'); > >>> > // or variations.. > >>> > } > > >>> > } > > >>> > result is empty. > > >>> > also i saw solution with creating new view class that will override > >>> > render function and customising it, but it sounds like overkill to > >>> > me.. > > >>> > ideal solution in addition to setting $viewPath ($this->viewPath = > >>> > 'shared') would be to change name of view file that will be requested > >>> > for rendering, but haven't found a way to do that. > > >>> > any ideas would be appreciated. > >>> > thanks. :) > > >>> -- > > >>> You received this message because you are subscribed to the Google Groups > >>> "CakePHP" group. > >>> To post to this group, send email to cake-...@googlegroups.com. > >>> To unsubscribe from this group, send email to > >>> cake-php+unsubscr...@googlegroups.com >>> om> > >>> . > >>> For more options, visit this group at > >>>http://groups.google.com/group/cake-php?hl=. -- You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-...@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=.
render shared view file
hi! i'm using Router::parseExtensions('json') to be able to request data delivered in json format, and i've been wondering if there's a way to change view file that will be used to render data? if action test from Examples controller ( /examples/test ) is requested, default view (app/views/examples/test.ctp) is rendered with default layout (app/views/layouts/default.ctp). if /examples/test.json is requested app/views/examples/json/test.ctp is rendered with app/views/layouts/json/default.ctp layout. because i use unified way for passing variables to view, i don't need every action to have different view for json extension (app/views/ examples/json/test1.ctp, app/views/examples/json/test2.ctp...), and i would like to use e.g. app/views/shared/json.ctp. i know how to achieve this for single action, but i need a way to do this globally (in AppController). what i tried: funciton beforeRender() { if ($this->RequestHandler->ext == 'json') { $this->viewPath = 'shared'; } } results in rendering app/views/shared/.ctp funciton beforeRender() { if ($this->RequestHandler->ext == 'json') { $this->render('/shared/json'); // or: $this->render('shared/json'); // or: $this->render(null, null, '/shared/json'); // or variations.. } } result is empty. also i saw solution with creating new view class that will override render function and customising it, but it sounds like overkill to me.. ideal solution in addition to setting $viewPath ($this->viewPath = 'shared') would be to change name of view file that will be requested for rendering, but haven't found a way to do that. any ideas would be appreciated. thanks. :) -- You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-...@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=.
Re: behaving the CakePHP 1.2 way
i solved it this way: - named form field 'password1' (or whatever) - validated that field in User model - hashed it with AuthComponent::password() in User::beforeSave() - placed it in $this->data['User']['password'] (and unset $this->data ['User']['password1']) On Jan 30, 2:11 am, Delirium tremens wrote: > This part of the problem has been solved. > > On 29 jan, 15:06, Delirium tremens wrote: > > > > > What else should I try? > > > On 29 jan, 15:01, Delirium tremens wrote: > > > > The code from the site: > > > > function hashPasswords($data, $enforce=false) { > > > if($enforce && isset($this->data[$this->alias]['password'])) { > > > if(!empty($this->data[$this->alias]['password'])) { > > > $this->data[$this->alias]['password'] = Security::hash > > > ($this->data[$this->alias]['password'], null, true); > > > } > > > } > > > return $data; > > > } > > > function beforeSave() { > > > $this->hashPasswords(null, true); > > > return true; > > > } > > > > I tried: > > > - the code without changes > > > - the code with alias changed to userModel > > > - the code with null changed to $data > > > - the code with null changed to $this->data > > > > The codes I tried are not encrypting the password after validating it. > > > > On 29 jan, 12:18, "j0n4s.h4rtm...@googlemail.com" > > > > wrote: > > > > I did not try this yet, but this should help you, right?: > > > > >http://teknoid.wordpress.com/2008/10/08/demystifying-auth-features-in... > > > > > p.s. I believe the whole thing is because AuthComponent is > > > > AuthComponent and not AuthBehavior. If it came with such a thing it > > > > would be more clear (because hashing would take place in the model > > > > then) > > > > > On Jan 28, 8:04 pm, Delirium tremens wrote: > > > > > > there is no afterValidate > > > > > there is no beforeLogin > > > > > > What now??? > > > > > > On 28 jan, 16:47, Delirium tremens wrote: > > > > > > > I added: > > > > > > > function beforeSave() { > > > > > > $this->data['Account']['password'] = > > > > > > md5($this->data['Account'] > > > > > > ['password']); > > > > > > return true; > > > > > > > } > > > > > > > to Account model, but now login does not work. Why? > > > > > > > On 28 jan, 16:04, Delirium tremens wrote: > > > > > > > > Hold on... I need it encrypted after validated... What now??? > > > > > > > > On 28 jan, 15:53, Delirium tremens wrote: > > > > > > > > > I understood! I added it to BeforeFilter. It works! > > > > > > > > > On 28 jan, 15:37, Delirium tremens wrote: > > > > > > > > > > I added: > > > > > > > > > > $this->Auth->authenticate = $this->Account; > > > > > > > > > > to login. > > > > > > > > > > I added: > > > > > > > > > > function hashPasswords( $data ) { > > > > > > > > > return $data; > > > > > > > > > } > > > > > > > > > > to Account model. > > > > > > > > > > After updating my account, $cakeDebug (my debug config is 2, > > > > > > > > > so flash > > > > > > > > > is eternal) flashed my password hashed. Am I doing anything > > > > > > > > > wrong? > > > > > > > > > > On 27 jan, 21:34, Gonzalo Servat wrote: > > > > > > > > > > > On Tue, Jan 27, 2009 at 8:26 PM, Delirium tremens > > > > > > > > > > wrote: > > > > > > > > > > > > CakePHP 1.2 is encrypting passwords before validating > > > > > > > > > > > them. > > > > > > > > > > > > CakePHP 1.2 is trying to make us behave in a different > > > > > > > > > > > way. > > > > > > > > > > > > Are you behaving the CakePHP 1.2 way? > > > > > > > > > > > > What are you doing now that you are not allowed to > > > > > > > > > > > validate passwords? > > > > > > > > > > > I take it you're talking about the AuthComponent? If so, > > > > > > > > > > yes it hashes > > > > > > > > > > passwords automagically so you basically just store the > > > > > > > > > > hashed password in > > > > > > > > > > your DB. If you don't want that, you can do something like > > > > > > > > > > this: > > > > > > > > > > > $this->Auth->authenticate = $this->User; // or whatever ... > > > > > > > > > > > Inside the User model, you could have: > > > > > > > > > > > function hashPasswords( $data ) { > > > > > > > > > > return $data; > > > > > > > > > > > } > > > > > > > > > > > Instead of hashing the password, it just returns it > > > > > > > > > > unmodified (clear text). > > > > > > > > > > > - Gonzalo --~--~-~--~~~---~--~~ 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: usage of mapActions()
try using it this way: $this->Auth->mapActions(array (NAME_OF_THE_ACTION_1 => TYPE_OF_THE_ACTION, NAME_OF_THE_ACTION_2 => TYPE_OF_THE_ACTION, ...)); where TYPE_OF_THE_ACTION is 'create', 'read', 'update' or 'delete'. also, AFAIK, mapActions will have effect only if you are using Acl with Auth in actions/crud auth mode. On Dec 29, 4:49 am, "Arak Tai'Roth" wrote: > So I also looked over the api and everything that I am doing looks > right to me as far as what the api is expecting to receive. However > still when I click the link to take me to that action when I am logged > in it just refreshes the current page and does nothing. > > Any help would be appreciated. > > On Dec 28, 7:24 pm, "Arak Tai'Roth" wrote: > > > > > I guess I should probably note that the line I gave that I am using is > > in my beforeFilter function in my Builds Controller. I also tried it > > in the App Controller, but that didn't make a difference either. > > > On Dec 28, 2:55 pm, "Arak Tai'Roth" wrote: > > > > So I have this problem. I have a controller called BuildsController, I > > > have multiple edit pages within this controller as I have to edit > > > multiple data through it, but the data comes from multiple models, not > > > just the Build model. > > > > Anyways, so I have an edit() function, but also an editDescription() > > > function. When I login as an administrator I can access the edit > > > function, but I can't access the editDescription function until I > > > added it into $this->Auth->allow. But then it can be accessed without > > > logging in, which isn't what I want. > > > > So I was looking around and found the mapActions ability and wanted to > > > try that, so I have $this->Auth->mapActions(array('update' => array > > > ('editDescription'))) > > > > However that isn't working and I don't know if it's the way I am using > > > it or what it is. Any help on this matter would be appreciated, 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 -~--~~~~--~~--~--~---