Note that there are some explanatory texts on larger screens.

plurals
  1. POCakephp 2.2.4 does not save Auth User Info after using a alternative authenication
    text
    copied!<p>I am trying to create an authentication for facebook users. Right now I check to see if a fb user id exist in my database, if it does then it authenicates, if not, then it data mines the users facebook info and creates a user and then authenicates. It works successfully, the problem is, if I use something like <code>$this-&gt;Auth-&gt;user('id');</code> the values return back null. I am curious on what I maybe doing wrong. below is my code</p> <pre><code>public function fb_authenticate($data) { $this-&gt;Auth-&gt;fields = array('username' =&gt; 'fbid', 'password' =&gt; 'fbpassword'); $this-&gt;loadModel('User'); $user_record = $this-&gt;User-&gt;find('first', array( 'conditions' =&gt; array('fbid' =&gt; $data['user_id']) )); if(empty($user_record)) { $fbu = $this-&gt;Facebook-&gt;getUserInfo($data['user_id']); $user_record = array( 'User'=&gt;array( 'username'=&gt;$fbu-&gt;username, 'fbid'=&gt;$data['user_id'], 'oauth_token'=&gt;$data['oauth_token'], 'access_token'=&gt;$data['access_token'], 'firstname'=&gt;$fbu-&gt;first_name, 'lastname'=&gt;$fbu-&gt;last_name, 'fbpassword'=&gt;$this-&gt;Auth-&gt;password($data['user_id']), 'role'=&gt;'user' )); $this-&gt;User-&gt;create(); $this-&gt;User-&gt;save($user_record,null); } if (!$this-&gt;Auth-&gt;login($user_record)) { $this-&gt;Session-&gt;setFlash(__('Invalid username or password, try again')); } } </code></pre> <p>It authenicates and lets the user in, but it does not store the users info in the Auth component session. what could be the problem ??</p> <p>if I debug <code>debug($this-&gt;Auth-&gt;user())</code> I can see the data but if I pull a field individually <code>debug($this-&gt;Auth-&gt;user('id'));</code> it returns <code>null</code>. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload