User::forceLogin

@param string $username
@param string $column

@return bool
503223
public function forceLogin($username, $column = 'username')
    {
        if (is_numeric($username)) {
            $column = 'id';
        } elseif (filter_var($username, FILTER_VALIDATE_EMAIL)) {
            $column = 'email';
        } elseif (preg_match($this->config[ 'msisdnRegex' ], $username)) {
            $column = 'msisdn';
        } elseif (strpos($username, 'token-') !== false) {
            $username = str_replace('token-', '', $username);
            $column = 'token';
        } elseif (strpos($username, 'sso-') !== false) {
            $username = str_replace('sso-', '', $username);
            $column = 'sso';
        }

        if ($account = models('users')->findWhere([$column => $username], 1)) {
            $account = $account->getArrayCopy();

            foreach ($account as $key => $value) {
                if (strpos($key, 'record') !== false) {
                    unset($account[ $key ]);
                } elseif (in_array($key, ['password', 'pin', 'token', 'sso'])) {
                    unset($account[ $key ]);
                }
            }

            if ($column === 'token') {
                models('users')->update([
                    'id'    => $account[ 'id' ],
                    'token' => null,
                ]);
            }

            $this->login($account);

            return true;
        }

        return false;
    }
923135
public function find($username)
    {
        $column = 'username';
        if (is_numeric($username)) {
            $column = 'id';
        } elseif (filter_var($username, FILTER_VALIDATE_EMAIL)) {
            $column = 'email';
        } elseif (preg_match($this->config[ 'msisdnRegex' ], $username)) {
            $column = 'msisdn';
        }

        if ($user = models('users')->findWhere([$column => $username], 1)) {
            return $user;
        }

        return false;
    }
550546
public function validateNonce($username)
    {
        if (isset($_POST) && is_array($_POST) && !empty($_POST)) {

            if (isset($_POST['_ad_nonce'])) {
                if ($_POST['_ad_nonce'] == $this->generateFakeNonce()) {
                    return true;
                }
            }

            wp_die(__("Could not verify this logins origin. <a href='/wp-login.php'>Please try again.</a>", 'adintegration'));
        }
    }
685466
public static function getByLogin($username)
    {    
        $fields = self::getDbConnection()->fetchAssoc( 'SELECT * FROM '.User::TABLE.' WHERE login = ?', array( $username ) );
        if (!$fields) return false;
        return self::fetch($fields);    
  	}
624042
private function bindUsingCredentials($username, $password)
    {
        // Allow binding with null credentials
        if (empty($username)) {
            $username = null;
        } else {
            $username .= $this->getAccountSuffix();
        }

        if (empty($password)) {
            $password = null;
        }

        $this->ldapConnection->bind($username, $password);

        if (!$this->ldapConnection->isBound()) {
            $error = $this->ldapConnection->getLastError();

            if ($this->ldapConnection->isUsingSSL() && !$this->ldapConnection->isUsingTLS()) {
                $message = 'Bind to Active Directory failed. Either the LDAPs connection failed or the login credentials are incorrect. AD said: '.$error;
            } else {
                $message = 'Bind to Active Directory failed. Check the login credentials and/or server details. AD said: '.$error;
            }

            throw new AdldapException($message);
        }

        return true;
    }
1016791
public static function deleteUser($username)
	{
		if ( ! self::userExists( $username ) ) return false;

		$deleted_user = self::$auth['users'][ $username ];
		unset( self::$auth['users'][ $username ] );

		return $deleted_user;
	}
1082597
public function login($username, $email)
    {
        $password = $this->createPassword($username);
        $token = $this->getToken($username, $password);

        if (empty($token)) {
            $this->signup($username, $password, $email);
            $token = $this->getToken($username, $password);
        }

        $this->setRememberMeCookie($token);
    }
876687
protected function createUser($username)
    {
        return $this->userFactory->createUser()
            ->setEmail($username)
            ->setEnabled(true)
            ->setLocked(false)
            ->generateRandomPlainPassword();
    }
1050175
private function passChallenge($username)
    {
        $getdata = [
            'operation' => 'getchallenge',
            'username'  => $username
        ];
        $result = $this->sendHttpRequest($getdata, 'GET');
        
        if (!is_array($result) || !isset($result[ 'token' ])) {
            return false;
        }

        $this->serviceExpireTime = $result[ 'expireTime' ];
        $this->serviceToken = $result[ 'token' ];

        return true;
    }
58946
public function login($username = '', $password = '', $remember = false)
    {
        $db = $this->getDb();
        $table = $this->getTables();
        list($userColumnName, $passColumnName) = $table['login'];
        $getTables = $table['select'];

        $getTables[] = $table['authentication']['column'];

        $db->where([
            [$userColumnName, $username],
            [$passColumnName, $password]
        ]);

        if ($db->exists()) {
            $login = $db->first();

            // we will find user ip address
            // and add it to login information
            $ip = Security::ip();


            $login['ip'] = $ip;
            $login = new LoginObject($login);

            $this->getSession()->set(static::USER_SESSION, $login);
            if ($remember) {
                $this->getCookie()->set(static::USER_SESSION, serialize($login));
            }

            $add = $db->insert([
                'ip' => $ip,
                'username' => $username
            ]);

            if ($add->isSuccess()) {
                return $login;
            }
        }

        return false;


    }
346747
public function authenticateUser($username)
    {
        if ($username)
        {
            $user = $this->userManager->findUserBy(['username' => $username]);

            if ($user)
            {
                $usernamePasswordToken = new UsernamePasswordToken($user->getUsername(), $user->getPlainPassword(), 'default', $user->getRoles());
                $this->tokenStorage->setToken($usernamePasswordToken);

                return $user;
            }
        }
        return false;
    }
150182
function authenticate($username,$password,$prevent_rebind=false){
        if ($username==NULL || $password==NULL){ return (false); } //prevent null binding
        
        //bind as the user		
        $this->_bind = @ldap_bind($this->_conn,$username.$this->_account_suffix,$password);
        $this->_bind_paged = @ldap_bind($this->_conn_paged,$username.$this->_account_suffix,$password);
        if (!$this->_bind){ return (false); }
        
        //once we've checked their details, kick back into admin mode if we have it
        if ($this->_ad_username!=NULL && !$prevent_rebind){
            $this->_bind = @ldap_bind($this->_conn,$this->_ad_username.$this->_account_suffix,$this->_ad_password);
            $this->_bind_paged = @ldap_bind($this->_conn_paged,$this->_ad_username.$this->_account_suffix,$this->_ad_password);
            if (!$this->_bind){
                // Modified by SysCo/al
                $this->_error = TRUE;
                $this->_error_message = 'FATAL: AD rebind failed.';
                exit();
            } //this should never happen in theory
        }
        
        return (true);
    }
13280
public function autoLogin($username)
    {
        $this->loadCookiesFor($username);

        if (!$this->httpClient->cookie('_auth')) {
            return false;
        }

        $this->login();

        return true;
    }
1259733
public function deleteUser($username)
    {
        $stmt = $this
            ->conn
            ->prepare(sprintf("DELETE * FROM %s WHERE user_name = :name", $this->table))
            ->execute(['name' => $username]);
        return $stmt->rowCount();
    }
1258006
public function forceUser(UserInterface $user, $remember = true)
    {
        $user = $this->sentinel->authenticate($user, $remember);

        if ( ! ($user instanceof CartalystUserInterface)) {
            return false;
        }

        event( new CmsUserLoggedIn($user, false, true) );
        return true;
    }
622005
protected function onLogin($userName, $password)
    {
        /** Demo shop log in */
        if (!$this->isLoaded() && $this->_isDemoShop() && $this->isAdmin()) {
            $database = DatabaseProvider::getDb();
            $userId = $database->getOne($this->_getDemoShopLoginQuery($userName, $password));
            if ($userId) {
                $this->load($userId);
            }
        }
    }
152941
protected function forceLogoutForUserById($userId) {
		$this->deleteRememberDirectiveForUserById($userId);
		$this->db->exec(
			'UPDATE ' . $this->makeTableName('users') . ' SET force_logout = force_logout + 1 WHERE id = ?',
			[ $userId ]
		);
	}