Beispiel #1
0
 public function IndexAction($params)
 {
     $oAuth = \Av\AuthController::GetAuth();
     $this->AddDebug(__METHOD__ . " #" . __LINE__ . " authentication obj:" . print_r($oAuth, true));
     // 1. Get registered and active Social Media to display on SignUp
     $arrMediaAuthLinks = array();
     $oMediaAuthMap = new \Av\MediaAuthTypeMapModel();
     // 1.1 what media(s) choices do we have for SignUp?
     $arrActiveSignUpMedia = $oMediaAuthMap->GetMediaAuthMap(array(\Av\MediaAuthTypeMapModel::AUTH_TYPE_ID => \Av\MediaAuthTypeModel::AUTH_TYPE_SIGNUP, \Av\MediaAuthTypeMapModel::STATUS => \Av\MediaAuthTypeMapModel::STATUS_ACTIVE));
     if ($arrActiveSignUpMedia !== false) {
         $arrActiveSignUpMedia = $arrActiveSignUpMedia[\Av\MediaAuthTypeModel::AUTH_TYPE_SIGNUP];
         //            $this->AddDebug(__METHOD__ . " #" . __LINE__ .  " \nActiveSignUpMedia:  \n" . print_r($arrActiveSignUpMedia,true) );
         $oMediaModel = new \Av\MediaModel();
         foreach ($arrActiveSignUpMedia as $currentMedia) {
             $params_media_info = array(\Av\MediaModel::MEDIA_ID => $currentMedia[\Av\MediaAuthTypeMapModel::MEDIA_ID]);
             $media_info = $oMediaModel->GetMediaInfo($params_media_info);
             //                $this->AddDebug(__METHOD__ . " #" . __LINE__ .  " \n media info:" . print_r($media_info,true) . "\n params are:" . print_r($params_media_info, true) . "\n");
             if (isset($media_info[\Av\MediaModel::MEDIA_NAME])) {
                 $state = \Av\UrlControllerHelper::packParamForUrl(array(\Av\Acl\RoleModel::ROLE_ID => \Av\Acl\RoleModel::ROLE_CLIENT_INT, \Av\MediaModel::MEDIA_ID => $currentMedia[\Av\MediaAuthTypeMapModel::MEDIA_ID]));
                 //                    $this->AddDebug(__METHOD__ . " #" . __LINE__ .  " \ packed state:  \n" . print_r($state, true));
                 $arrMediaAuthLinks['media_links'][$media_info[\Av\MediaModel::MEDIA_NAME]] = $this->LoginURL(array(self::STATE => $state, self::AUTH_TYPE_ID => $currentMedia[\Av\MediaAuthTypeMapModel::AUTH_TYPE_ID], self::MEDIA_ID => $currentMedia[\Av\MediaAuthTypeMapModel::MEDIA_ID]));
             }
         }
     }
     $this->GetView()->SetTemplateVars($arrMediaAuthLinks);
     //        $params_redirect    =   array(
     //            \Av\DispatcherController::MODULE_LC=>"Authorization",
     //            \Av\DispatcherController::CONTROLLER_LC=>"SignupController",
     //            \Av\DispatcherController::ACTION_LC=>"GoogleplusAction",
     //        );
     //        \Av\DispatcherController::Redirect($params_redirect);
     //        $this->AddDebug(__METHOD__ . " #" . __LINE__ .  " \nMedia:  \n" .  print_r($arrMediaAuthLinks, true));
 }
 public function GoogleAction($params)
 {
     // 1. Get authorization( token, refresh token)
     $oGAuth = new \Av\Authorization\Google\GoogleAuthResponseController();
     $oGAuth->GetAuthResponse($params);
     $STATE = $oGAuth->service_auth->GetState();
     $ROLE_ID = isset($STATE[\Av\Acl\RoleModel::ROLE_ID]) ? (int) $STATE[\Av\Acl\RoleModel::ROLE_ID] : null;
     $MEDIA_ID = isset($STATE[\Av\MediaModel::MEDIA_ID]) ? (int) $STATE[\Av\MediaModel::MEDIA_ID] : null;
     $USER_ID = \Av\AuthController::GetAuth()->GetUserId();
     $TOKEN = $oGAuth->service_auth->GetToken();
     $REFRESH_TOKEN = $oGAuth->service_auth->GetRefreshToken();
     // 2. prepare user authorization info to save in DB
     $params_social = array(\Av\MediaUserModel::MEDIA_ID => $MEDIA_ID, \Av\MediaUserModel::ACCESS_TOKEN => $TOKEN, \Av\MediaUserModel::REFRESH_TOKEN => $REFRESH_TOKEN, \Av\MediaUserModel::USER_ID => $USER_ID, \Av\UserModel::ROLE_ID => $ROLE_ID);
     // 3. Get personal Information. Can pull from G+ only. Add to user authorization info.
     if ($MEDIA_ID === \Av\MediaModel::MEDIA_GOOGLE_PLUS) {
         //            $arrEMAILs      =   $oGAuth->GetUserEmails();
         //            $this->AddDebug(__METHOD__ . " #" . __LINE__ . " google emails as object is:" . print_r($arrEMAILs, true));
         //            $arrEMAILs_as_array =   $oGAuth->GetUserEmailsAsArray();
         //            $this->AddDebug(__METHOD__ . " #" . __LINE__ . " google emails as array is:" . print_r($arrEMAILs_as_array, true));
         //            $EMAIL          =   $oGAuth->GetUserAccountEmail();
         //            $this->AddDebug(__METHOD__ . " #" . __LINE__ . " google+ account email is:" . print_r($EMAIL, true));
         //            $DISPLAY_NAME   =   $oGAuth->GetName();
         //            $SOCIAL_USER_ID =   $oGAuth->GetMediaUserId();
         $this->AddDebug(__METHOD__ . " #" . __LINE__ . " google auth/person is:" . print_r($oGAuth, true));
         $params_social[\Av\UserModel::USER_EMAIL] = $oGAuth->service_person->GetUserAccountEmail();
         $params_social[\Av\UserModel::DISPLAY_NAME] = $oGAuth->service_person->GetName();
         $params_social[\Av\MediaUserModel::SOCIAL_USER_ID] = $oGAuth->service_person->GetMediaUserId();
     }
     $this->AddDebug(__METHOD__ . " #" . __LINE__ . " save params are:" . print_r($params_social, true));
     $user = $this->SaveUser($params_social);
 }
Beispiel #3
0
 public function LogOutAction($params)
 {
     \Av\AuthController::LogOut();
 }
Beispiel #4
0
 /**
  * @return int authenticated user id. NULL if user is not loged in
  */
 public function GetAuthUserId()
 {
     return (int) \Av\AuthController::GetAuth()->GetUserId();
 }