Oh heavens...

Paulos, you also need to configure your Auth properly so your login()
function will be called after your user logs in.

Id est: $this->Auth->autoRedirect = false; in your AppController along
with all the other Auth stuff.

HTH

On May 19, 3:07 pm, andy <[email protected]> wrote:
> What displays when you print_r($this->Session) or print_r($_SESSION)?
>
> On May 18, 7:21 am, paulos nikolo <[email protected]> wrote:
>
> > it prints this
>
> > AuthComponent Object
> > (
> >     [_loggedIn] =>
> >     [components] => Array
> >         (
> >             [0] => Session
> >             [1] => RequestHandler
> >         )
>
> >     [authenticate] =>
> >     [authorize] => controller
> >     [ajaxLogin] =>
> >     [userModel] => User
> >     [userScope] => Array
> >         (
> >         )
>
> >     [fields] => Array
> >         (
> >             [username] => username
> >             [password] => password
> >         )
>
> >     [sessionKey] => Auth.User
> >     [actionPath] =>
> >     [loginAction] => Array
> >         (
> >             [controller] => users
> >             [action] => login
> >         )
>
> >     [loginRedirect] => Array
> >         (
> >             [controller] => users
> >             [action] => index
> >         )
>
> >     [logoutRedirect] => Array
> >         (
> >             [controller] => users
> >             [action] => login
> >         )
>
> >     [object] =>
> >     [loginError] => Invalid username or password
> >     [authError] => You are not authorized to access that location.
> >     [autoRedirect] => 1
> >     [allowedActions] => Array
> >         (
> >             [0] => display
> >             [1] => index
> >             [2] => add
> >         )
>
> >     [actionMap] => Array
> >         (
> >             [index] => read
> >             [add] => create
> >             [edit] => update
> >             [view] => read
> >             [remove] => delete
> >             [create] => create
> >             [read] => read
> >             [update] => update
> >             [delete] => delete
> >         )
>
> >     [data] =>
> >     [params] => Array
> >         (
> >             [pass] => Array
> >                 (
> >                 )
>
> >             [named] => Array
> >                 (
> >                 )
>
> >             [controller] => users
> >             [action] => login
> >             [plugin] =>
> >             [form] => Array
> >                 (
> >                 )
>
> >             [url] => Array
> >                 (
> >                     [url] => users/login
> >                 )
>
> >         )
>
> >     [_methods] => Array
> >         (
> >             [1] => index
> >             [2] => view
> >             [3] => add
> >             [4] => delete
> >             [5] => edit
> >             [6] => change_status
> >             [7] => login
> >             [8] => logout
> >         )
>
> >     [_log] =>
> >     [enabled] => 1
> >     [Session] => SessionComponent Object
> >         (
> >             [__active] => 1
> >             [__started] => 1
> >             [__bare] => 0
> >             [valid] => 1
> >             [error] =>
> >             [_userAgent] => 99eaa36d863fae669cb83f33c1ad01af
> >             [path] => /my_cake/index.php
> >             [lastError] =>
> >             [security] => high
> >             [time] => 1242649223
> >             [sessionTime] => 1242649233
> >             [watchKeys] => Array
> >                 (
> >                 )
>
> >             [id] =>
> >             [_log] =>
> >             [host] => localhost
> >             [enabled] => 1
> >             [cookieLifeTime] => 0
> >         )
>
> >     [RequestHandler] => RequestHandlerComponent Object
> >         (
> >             [ajaxLayout] => ajax
> >             [enabled] => 1
> >             [__responseTypeSet] =>
> >             [params] => Array
> >                 (
> >                 )
>
> >             [__requestContent] => Array
> >                 (
> >                     [javascript] => text/javascript
> >                     [js] => text/javascript
> >                     [json] => application/json
> >                     [css] => text/css
> >                     [html] => Array
> >                         (
> >                             [0] => text/html
> >                             [1] => */*
> >                         )
>
> >                     [text] => text/plain
> >                     [txt] => text/plain
> >                     [csv] => Array
> >                         (
> >                             [0] => application/vnd.ms-excel
> >                             [1] => text/plain
> >                         )
>
> >                     [form] => application/x-www-form-urlencoded
> >                     [file] => multipart/form-data
> >                     [xhtml] => Array
> >                         (
> >                             [0] => application/xhtml+xml
> >                             [1] => application/xhtml
> >                             [2] => text/xhtml
> >                         )
>
> >                     [xhtml-mobile] => application/vnd.wap.xhtml+xml
> >                     [xml] => Array
> >                         (
> >                             [0] => application/xml
> >                             [1] => text/xml
> >                         )
>
> >                     [rss] => application/rss+xml
> >                     [atom] => application/atom+xml
> >                     [amf] => application/x-amf
> >                     [wap] => Array
> >                         (
> >                             [0] => text/vnd.wap.wml
> >                             [1] => text/vnd.wap.wmlscript
> >                             [2] => image/vnd.wap.wbmp
> >                         )
>
> >                     [wml] => text/vnd.wap.wml
> >                     [wmlscript] => text/vnd.wap.wmlscript
> >                     [wbmp] => image/vnd.wap.wbmp
> >                     [pdf] => application/pdf
> >                     [zip] => application/x-zip
> >                     [tar] => application/x-tar
> >                 )
>
> >             [__acceptTypes] => Array
> >                 (
> >                     [0] => text/html
> >                     [1] => application/xhtml+xml
> >                     [2] => application/xml
> >                     [3] => */*
> >                 )
>
> >             [__renderType] =>
> >             [ext] =>
> >             [__typesInitialized] =>
> >             [_log] =>
> >         )
>
> > )
>
> > 2009/5/18 andy <[email protected]>
>
> > > If you print_r($this->Auth), what keys/values are included in the
> > > array?
>
> > > On May 18, 4:09 am, paulos nikolo <[email protected]> wrote:
> > > > Yeah Andy i tried this but still nothing.Dunno what else i have to 
> > > > do.Thx
> > > > anyway for your idea!
>
> > > > 2009/5/18 andy <[email protected]>
>
> > > > > I may be wrong, but I believe '$this->Auth->user()' would look for the
> > > > > function 'user()' within Auth rather than an array value. Have you
> > > > > tried '$this->Auth->user['id']' before calling saveField?
>
> > > > > On May 17, 5:43 am, paulos nikolo <[email protected]> wrote:
> > > > > > Still nothing Faza.I am wondering if i have to do something else to
> > > get
> > > > > it
> > > > > > work.I think --> if ($this->Auth->user()) doesnt seem to work.If i
> > > erase
> > > > > > this line cake save the last_login but in a new row.
>
> > > > > > 2009/5/16 Faza <[email protected]>
>
> > > > > > > This is the code I'm using, works 100%.
>
> > > > > > > function login() {
> > > > > > >        $this->layout = 'login';
> > > > > > >        if ($this->Auth->user()) {
> > > > > > >             $this->User->id = $this->Auth->user('id');
> > > > > > >             $this->User->saveField('last_visit', 'now()');
> > > > > > >            $gr =
> > > > > > > $this->User->Group->findById($this->Auth->user('group_id'));
> > > > > > >            $this->Session->write('Auth.User.group',
> > > > > $gr['Group']['name']);
> > > > > > >            $this->Session->write('Auth.User.password', "");
> > > > > > >            $this->redirect($this->Auth->redirect());
> > > > > > >        }
> > > > > > >    }
>
> > > > > > > Paulos23 pisze:
> > > > > > > > Hi Cake people,
> > > > > > > > I have spent much time in make this work but nothing.I am using
> > > auth
> > > > > > > > which is working ok and i want to update the last_login field in
> > > > > users
> > > > > > > > table.But i can't.Most of my attempts lead to create a new row 
> > > > > > > > in
> > > > > > > > table with an empty user contained the updated field.I have read
> > > all
> > > > > > > > of the previous  posts here but nothing help me.Can you tell me
> > > if I
> > > > > > > > do something wrong.Here i put my code:
>
> > > > > > > > app_controller:
>
> > > > > > > > class AppController extends Controller {
> > > > > > > >       var $components = array('Auth');
> > > > > > > >       function beforeFilter() {
> > > > > > > >               $this->Auth->loginAction = array('controller' =>
> > > > > 'users',
> > > > > > > 'action'
> > > > > > > > => 'login');
> > > > > > > >        
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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