Sorry, I also meant to add (before being distracted by my stupid
keyboard) was to explain this section of code I used above.
I was thinking I could fix it using this:
$this->User->id = $id;
$this->User->group_id = $this->Session->read('Auth.User.group_id');
$this->User->saveField('last_login', date('Y-m-d H:i:s'));
but then realized the field being set to null is an index based on the
aros table id, not the actual group_id. So just ignore it.
On Jul 9, 4:16 pm, Anthony <[email protected]> wrote:
> I've been working on this for a few days now and something just isn't
> right.
>
> My first thought was to simply add something like this in the user
> controllers login action:
>
> but it was never getting called. So I went back to my app_controller
> and disabled my loginRedirect setting and added the redirect after the
> call so we had something like this:
>
> users_controller - login():
>
> $this->User->saveField('last_login', date('Y-m-d H:i:s'));
> $this->redirect($dashboard_url);
>
> app_controller:
>
> function beforeFilter() {
> $this->Auth->authorize = 'actions';
> $this->Auth->fields = array('username' => 'name', 'password'
> => 'password');
> $this->Auth->loginAction = array('controller' => 'users',
> 'action' => 'login');
> $this->Auth->actionPath = 'controllers/';
> $this->Auth->autoRedirect = false;
> $this->Auth->allowedActions = array('display');
>
> }
>
> With this setup a new row was added to my users table so I added:
>
> users_controller -
>
> function login() {
> // Check for a successful login
> if (!empty($this->data) && $id = $this->Auth->user('id')) {
>
> // Set the lastlogin time
> $this->User->id = $id;
> $this->User->saveField('last_login', date('Y-m-
> d H:i:s'));
>
> $this->redirect($dashboard_url);
> }
> }
>
> Eureka! It works and updates the users table but now the user is no
> longer allowed to access any of the controllers/actions they were
> allowed to. I can fix it on a per-user basis by allowing full access
> to the users controller and simply editing and saving the user without
> making any changes.
>
> So, my assumption is something is going wrong with updating the aros
> table, so I take a look and sure enough after attempting to log in the
> parent field in the aros table becomes null instead of the parent
> items aros tables id.
>
> $this->User->id = $id;
> $this->User->group_id =
> $this->Session->read('Auth.User.group_id');
>
> $this->User->saveField('last_login', date('Y-m-
> d H:i:s'));
>
> I'm using the controller from the cakephp documentation with the
> exception of using UUID for user and group id's intead of int. I did
> update the foreign_key field to varchar(36). Login and acl work great
> when I do not update the lat_login field.
>
> ThiS haS gotten a bit longer than I intended but I think I've included
> moSt relevant info and my 'S' Stopped working in the laSt paragraph So
> thankS in advanced and if further information i required feel free to
> aSk, and Sorry to not have included it.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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