Hey guys,
I'm having some difficulties figuring out what everything really does in
this UserController. I inherited this from a previous developer and I'm
not entirely sure what the functions do. It's not working as intended. Any
help understanding why this isn't an effective UserController file would be
appreciated.
Okay, so beforeFilter() is called when? Isn't it just supposed to return
false or true? Why is it asking for $this->Auth stuff?
beforeFacebookSave() is different from beforeFilter() in what way?
I get afterLogin(), I think.
Why is nothing under login()?
logout(), I think I'm clear on that as well.
like_site() is for a custom tracking feature of the site, I don't think it
works and from the looks of it, it doesn't seem to do much at this point.
fbLogin() is the most mission critical part, I assume.
There is a sign up process but I think the code to save that info is stored
elsewhere.
*Guys, I'm just really in need of some guidance and ANY help would be
appreciated. *
> class UsersController extends AppController {
>
> function beforeFilter(){
>
> parent::beforeFilter();
>
> $this->Connect->noAuth = false;
>
>
>> $this->Auth->allow('login', 'fbLogin', 'afterLogin', 'logout',
>> 'like_site', 'getMyBandId','getMyPageFans');
>
> $this->Auth->fields = array('username' => 'email', 'password' =>
>> 'password');
>
> }
>
> function beforeFacebookSave() {
>
> $this->Connect->authUser['User']['email'] = $this->Connect->user('email');
>
> $this->Connect->authUser['User']['first_name'] =
>> $this->Connect->user('first_name');
>
> $this->Connect->authUser['User']['last_name'] =
>> $this->Connect->user('last_name');
>
> return true;
>
> }
>
> function afterLogin(){
>
>
>> $this->autoRender = false;
>
> //$this->redirect($this->referer());
>
> }
>
> function login(){
>
>
>> }
>
> /////////////////////////////////////// start logout
>> //////////////////////////
>
> function logout() {
>
> $this->autoRender = false;
>
> // $this->destroySession();//exit;
>
>
>> $this->Session->delete('Auth');
>
> $this->Session->destroy();
>
> // unset cookies
>
> $this->uid = null;
>
> $this->Auth->logout();
>
> $this->redirect(array('controller'=>'pages','action'=>'display','home'));
>
> }
>
> //////////////////////////////////// end logout
>> //////////////////////////////
>
> public function signout(){
>
>
>> $this->redirect('/');
>
>
>> }
>
>
>> function like_site(){
>
> $this->autoRender = false;
>
> if (!$this->RequestHandler->isAjax()) {
>
> return;
>
> }
>
>
>
>
>> }
>
>
>>
>>
>>
>> function fbLogin($field=null) {
>
> $Facebook = new Facebook(FacebookInfo::getConfig());
>
> $accessToken = $Facebook->getAccessToken();
>
>
>> //$user = false;
>
> // echo $this->Auth->user('id');exit;
>
>
>> if (!$this->Auth->user('id')) {
>
> if ($this->Connect->__syncFacebookUser()) {
>
> //$this->User->updateLastLogin($this->Auth->user('id'));
>
> $user = $this->Auth->user();
>
> }
>
> $user['redirect'] = 1;
>
> } else {
>
> $user = $this->Auth->user();
>
> $user['redirect'] = 0;
>
> }
>
> $user['band_id'] = $this->getMyBandId($user['id']);
>
> $this->autoRender = false;
>
> $udetail = $this->fbUserDetails($user['facebook_id'],$accessToken);
>
> App::import('Model', 'User');
>
> $this->User = new User();
>
> $userdatanow = $this->User->findByFacebookId($user['facebook_id']);
>
> $locationID = $udetail['location']->id;
>
> $user['email'] = $udetail['email'];
>
> $user['first_name'] = $udetail['first_name'];
>
> $user['last_name'] = $udetail['last_name'];
>
> if(empty($userdatanow['User']['city']) ||
>> empty($userdatanow['state']['country']) ||
>> empty($userdatanow['User']['zipcode'])) {
>
> $locationArray = $this->fbLocationDetails($locationID);
>
> $user['city'] = $locationArray['city'];
>
> $user['state'] = $locationArray['state'];
>
> $user['country'] = $locationArray['country'];
>
> $user['zipcode'] = $locationArray['zipcode'];
>
>
>> } else {
>
> $user['city'] = $userdatanow['city'];
>
> $user['state'] = $userdatanow['state'];
>
> $user['country'] = $userdatanow['country'];
>
> $user['zipcode'] = $userdatanow['zipcode'];
>
> }
>
>
>> if(empty($userdatanow['User']['first_name']) ||
>> empty($userdatanow['User']['last_name']) ||
>> empty($userdatanow['User']['email']) || empty($userdatanow['User']['city'])
>> || empty($userdatanow['state']['country']) ||
>> empty($userdatanow['User']['zipcode'])){
>
>
>> $data = array(
>
> 'User' => array(
>
> 'id' => $userdatanow['User']['id'],
>
> 'first_name' => $udetail['first_name'],
>
> 'last_name' => $udetail['last_name'],
>
> 'email' => $udetail['email'],
>
> 'city' => $user['city'],
>
> 'state' => $user['state'],
>
> 'country' => $user['country'],
>
> 'zipcode' => $user['zipcode']
>
> )
>
> );
>
> $this->User->save($data, false,
>> array('first_name','last_name','email','city','state','country','zipcode'));
>
> }
>
> print json_encode($user);
>
> }
>
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.