Nope, this just isn't working right.
Adding the before filter to the app_controller.php worked. Then I
wanted to add an allow to my TwitchersController so that the add
method would be available for people to add new Twitchers (users).
The allow worked OK; but when I submitted the add form I got the
following message:
Error: Database table users for model User was not found.
So why is it persisting in looking for Users. Here's my add method
from the TwitchersController:
function add() {
if (!empty($this->data)) {
$this->Twitcher->create();
$this->data['Twitcher']['password'] =
$this->Auth->password($this-
>data['Twitcher']['password']);
if ($this->Twitcher->save($this->data)) {
$this->Session->setFlash(__('The Twitcher has
been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Twitcher could
not be saved.
Please, try again.', true));
}
}
}
To me it looks like this is a bug as the override for the user table /
model just doesn't seem to work.
David
On Dec 14, 10:51 pm, gearvOsh <[email protected]> wrote:
> Have you tried placing the Auth information in AppControllers
> beforeFilter()? Try that and see what happens... and if that doesnt
> help, look in the Auth Component manually.
>
> On Dec 14, 11:59 am, DavidH <[email protected]> wrote:
>
> > Please note that since the above post I've corrected the model name to
> > Twitcher as opposed to Twitchers; but it still doesn't work.
>
> > function beforeFilter()
> > {
> > $this->Auth->userModel = 'Twitcher';
> > $this->Auth->loginAction = array('controller' =>
> > 'twitchers',
> > 'action' => 'login');
> > // $this->Auth->allow('view');
> > $this->Auth->redirectLogin = array('controller' => 'birds',
> > 'action'
> > => 'view');
> > }
>
> > On Dec 14, 7:55 pm, DavidH <[email protected]> wrote:
>
> > > Hi
>
> > > That's what I thought too. Here's one of my controllers:
>
> > > class BirdsController extends AppController {
> > > var $name = 'Birds';
> > > var $scaffold;
> > > var $components = array('Auth');
>
> > > function beforeFilter()
> > > {
> > > $this->Auth->userModel = 'Twitchers';
> > > $this->Auth->loginAction = array('controller' =>
> > > 'twitchers',
> > > 'action' => 'login');
> > > // $this->Auth->allow('view');
> > > $this->Auth->redirectLogin = array('controller' =>
> > > 'birds', 'action'
> > > => 'view');
> > > }
>
> > > }
>
> > > However running any action in the birds view results in the above
> > > mentioned error looking for a users controller.
>
> > > On Dec 14, 6:48 pm, thatsgreat2345 <[email protected]> wrote:
>
> > > > That line should be in the beforeFilter , is that where it is located,
> > > > if it is being used through out your controllers create an
> > > > app_controller.php and add a beforeFilter to it that way auth is used
> > > > by all your controllers, as well as you will only have to define the
> > > > table once rather than in each controller.
>
> > > > On Dec 14, 10:19 am, DavidH <[email protected]> wrote:
>
> > > > > Sorry for the confusion.
>
> > > > > Model: Twitcher
> > > > > DB Table: Twitchers
> > > > > Controller: twitchers_controller.php
>
> > > > > I'm sure the Twitcher(s) stuff is OK. Why isn't it acting on my
> > > > > userModel assignment?
>
> > > > > David
>
> > > > > On Dec 14, 5:50 pm, thatsgreat2345
> > > > > <[email protected]> wrote:
>
> > > > > > The model is called Twichers? The model should be singular, called
> > > > > > Twicher(models/twicher.php), the table in the database should be
> > > > > > called twichers, and controller should be twichers_controller.php
> > > > > > which you have.
>
> > > > > > On Dec 14, 5:14 am, DavidH <[email protected]>
> > > > > > wrote:
>
> > > > > > > Hi
>
> > > > > > > I'm sure there must be a simple solution to this; but I just
> > > > > > > can't get
> > > > > > > it working.
>
> > > > > > > I'm using CakePHP version 1.2.0.7296 RC2 and I'm trying to
> > > > > > > implement
> > > > > > > authorization using the Auth component. My application uses a
> > > > > > > table /
> > > > > > > model called "Twitchers" instead of users and so I've included the
> > > > > > > line:
>
> > > > > > > $this->Auth->userModel = 'Twitcher';
>
> > > > > > > throughout my controllers. Howeevr it doesn't matter how many
> > > > > > > times I
> > > > > > > include this line Cake persistently tells me it can't find the
> > > > > > > UsersController in app/controllers/users_controller.php.
>
> > > > > > > I do have a TwitchersController in twitchers_controller.php.
>
> > > > > > > I've peppered just about every controller method with the
> > > > > > > userModel
> > > > > > > assignment; but I just can't get Cake to accept it.
>
> > > > > > > What have I omitted or done wrong?
>
> > > > > > > Thanks
>
> > > > > > > David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---