Beispiel #1
0
 /**
  * ifAllowedToLogin() method (set and reset allowed_to_login)
  */
 function testIfAllowedToLogin()
 {
     $contactId = Contact::createIndividual();
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'endpoint_url' => $openid['endpoint_url'], 'claimed_id' => $openid['claimed_id'], 'display_id' => $openid['display_id'], 'is_primary' => 1);
     require_once 'CRM/Core/BAO/OpenID.php';
     $openObject = CRM_Core_BAO_OpenID::add($params);
     $openid_id = $openObject->id;
     $this->assertDBCompareValues('CRM_Core_DAO_OpenID', array('id' => $openid_id), $openid);
     $allowedToLogin = CRM_Core_BAO_OpenID::isAllowedToLogin($openid);
     $this->assertEquals($allowedToLogin, false, 'Verify allowed_to_login value is 0.');
     // Now call add() to modify an existing OpenID record
     $params = array('id' => $openid_id, 'contact_id' => $contactId, 'is_bulkmail' => 1, 'allowed_to_login' => 1);
     CRM_Core_BAO_OpenID::add($params);
     $allowedToLogin = CRM_Core_BAO_OpenID::isAllowedToLogin($openid);
     $this->assertEquals($allowedToLogin, true, 'Verify allowed_to_login value is 1.');
     Contact::delete($contactId);
 }
Beispiel #2
0
 /**
  * IfAllowedToLogin() method (set and reset allowed_to_login)
  */
 public function testIfAllowedToLogin()
 {
     $contactId = Contact::createIndividual();
     $this->assertDBRowExist('CRM_Contact_DAO_Contact', $contactId);
     $openIdURL = "http://test-username.civicrm.org/";
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'openid' => $openIdURL, 'is_primary' => 1);
     $openObject = CRM_Core_BAO_OpenID::add($params);
     $openId = $openObject->id;
     $this->assertDBNotNull('CRM_Core_DAO_OpenID', $openIdURL, 'id', 'openid', 'Database check for created OpenID.');
     $allowedToLogin = CRM_Core_BAO_OpenID::isAllowedToLogin($openIdURL);
     $this->assertEquals($allowedToLogin, FALSE, 'Verify allowed_to_login value is 0.');
     // Now call add() to modify an existing open-id record
     $params = array('id' => $openId, 'contact_id' => $contactId, 'openid' => $openIdURL, 'is_bulkmail' => 1, 'allowed_to_login' => 1);
     CRM_Core_BAO_OpenID::add($params);
     $allowedToLogin = CRM_Core_BAO_OpenID::isAllowedToLogin($openIdURL);
     $this->assertEquals($allowedToLogin, TRUE, 'Verify allowed_to_login value is 1.');
     $this->contactDelete($contactId);
     //domain contact doesn't really get deleted //
     $this->assertDBRowNotExist('CRM_Contact_DAO_Contact', $contactId);
 }
Beispiel #3
0
 /**
  * Get if the user is allowed to login 
  *
  * @param $user the user object holding auth info
  *
  * @return boolean
  * @access public
  * @static
  */
 static function getAllowedToLogin($user)
 {
     require_once 'CRM/Core/BAO/OpenID.php';
     // this returns true if the user is allowed to log in, false o/w
     $allow_login = CRM_Core_BAO_OpenID::isAllowedToLogin($user->openid);
     return $allow_login;
 }