/**
  * Checks if a user is a sugarLogin user
  * which implies they should use the sugar authentication to login
  *
  * @param STRING $name
  * @param STRIUNG $password
  * @return boolean
  */
 function isSugarLogin($name, $password)
 {
     $row = User::findUserPassword($name, $password, "(portal_only IS NULL OR portal_only !='1') AND (is_group IS NULL OR is_group !='1') AND status !='Inactive' AND sugar_login=1");
     return !empty($row);
 }
Example #2
0
 public function change_password($id)
 {
     $user = new User();
     $user->retrieve($id);
     //execute the method and verifh that it returns true
     $result = $user->change_password("test", "testpass");
     $this->assertEquals(true, $result);
     //find the user by new password
     $result = User::findUserPassword("test", md5("testpass"));
     $this->assertTrue(isset($result['id']));
     $this->assertEquals($id, $result['id']);
 }
Example #3
0
function login_user($portal_auth)
{
    $error = new SoapError();
    $user = User::findUserPassword($portal_auth['user_name'], $portal_auth['password'], "portal_only='1' AND status = 'Active'");
    if (!empty($user)) {
        global $current_user;
        $bean = new User();
        $bean->retrieve($user['id']);
        $current_user = $bean;
        return 'success';
    } else {
        $GLOBALS['log']->fatal('SECURITY: User authentication for ' . $portal_auth['user_name'] . ' failed');
        return 'fail';
    }
}
function login_user($portal_auth)
{
    $error = new SoapError();
    $user = User::findUserPassword($portal_auth['user_name'], $portal_auth['password'], "portal_only='1' AND status = 'Active'");
    if (!empty($user)) {
        global $current_user;
        $bean = BeanFactory::getBean('Users', $user['id']);
        $current_user = $bean;
        $sessionManager = new SessionManager();
        if (!$sessionManager->canAddSession()) {
            //not able to add another session right now
            $GLOBALS['log']->debug("Unable to add new session");
            return 'sessions_exceeded';
        }
        return 'success';
    } else {
        $GLOBALS['log']->fatal('SECURITY: User authentication for ' . $portal_auth['user_name'] . ' failed');
        return 'fail';
    }
}