CakeDC/users

$this->getRequest->getSession()->read('Auth')

tgoeminne opened this issue · 2 comments

if you use this $this->getRequest->getSession()->read('Auth') instead of $this->Auth->User('id')

then the first request it will be empty because the session not in request?

Then when you refresh the page again, the User is logged in and $this->getRequest->getSession()->read('Auth') no longer empty.

Why is this empty the first time you hit the page? Should the user not be logged in on the first request when using remember me?

$this->Auth->User('id') this has been removed now for whatever reason because it was doing good work.

Now the replacement is what? $this->Authentication->getIdentity() ? But this not available when use cakedc users. Do you need to load that component or how to use it?

I don't know but it seems to rely on the request->getSession()->read('Auth') seems to be not working very good,

the user seems to be logged in but the request session auth is empty...

I have used

$authenticationConfig = Configure::read('Auth.AuthenticationComponent');
$this->loadComponent('Authentication.Authentication', $authenticationConfig);

in appcontroller so I can use the    

    $authUser = $this->Authentication->getIdentity(); 

in other controllers...

is it normal that session Auth is empty but the user appears to be logged in?

You should rely on the request attribute identity instead of the session because identity may not be persisted into the session . Use $user = $this->getRequest()->getAttribute('identity');