That's brilliant and simple, thanks for that. I boiled it down a bit
to something that fits right into the AuthComponent, as follows. Not
sure if it is core-worthy as I am fairly new with cake, but I will use
it via a subclass of AuthComponent for now (since it looks like I will
have one anyway for other reasons)....


/**
 * Reloads the given field and value within in the session. If no
arguments
 * are given, will read the AuthComponent::userModel and re-load the
Session
 * using the result.
 *
 * @param string $field
 * @param string $value
 * @return void
 */
    function refresh($field = '', $value = '') {
        if (!empty($field) && !empty($value)) {
            $this->Session->write($this->sessionKey .'.'. $field,
$value);
        } elseif ($user =& $this->getModel()) {
            $this->login($user->read(false, $this->user('id')));
        }
    }

cheers ~
Sam


On Apr 2, 5:27 pm, Miles J <[email protected]> wrote:
> The auth session never resets itself unless you log back in. I created
> this method below:
>
>         /**
>          * Refreshes the Auth to get new data
>          * @param string $field
>          * @param string $value
>          * @return void
>          */
>         function _refreshAuth($field = '', $value = '') {
>                 if (!empty($field) && !empty($value)) {
>                         $this->Session->write($this->Auth->sessionKey .'.'. 
> $field,
> $value);
>                 } else {
>                         if (isset($this->User)) {
>                                 $this->Auth->login($this->User->read(false, 
> $this->Auth->user
> ('id')));
>                         } else {
>                                 
> $this->Auth->login(ClassRegistry::init('User')->findById($this->Auth->user('id')));
>
>                         }
>                 }
>         }
>
> Place that in your app_controller and call it like so: 
> $this->_refreshAuth('email', '[email protected]');
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to