REST_Controller::_check_login PHP Метод

_check_login() защищенный Метод

Check if the user is logged in
protected _check_login ( string $username = NULL, boolean | string $password = FALSE ) : boolean
$username string The user's name
$password boolean | string The user's password
Результат boolean
    protected function _check_login($username = NULL, $password = FALSE)
    {
        if (empty($username)) {
            return FALSE;
        }
        $auth_source = strtolower($this->config->item('auth_source'));
        $rest_auth = strtolower($this->config->item('rest_auth'));
        $valid_logins = $this->config->item('rest_valid_logins');
        if (!$this->config->item('auth_source') && $rest_auth === 'digest') {
            // For digest we do not have a password passed as argument
            return md5($username . ':' . $this->config->item('rest_realm') . ':' . (isset($valid_logins[$username]) ? $valid_logins[$username] : ''));
        }
        if ($password === FALSE) {
            return FALSE;
        }
        if ($auth_source === 'ldap') {
            log_message('debug', "Performing LDAP authentication for {$username}");
            return $this->_perform_ldap_auth($username, $password);
        }
        if ($auth_source === 'library') {
            log_message('debug', "Performing Library authentication for {$username}");
            return $this->_perform_library_auth($username, $password);
        }
        if (array_key_exists($username, $valid_logins) === FALSE) {
            return FALSE;
        }
        if ($valid_logins[$username] !== $password) {
            return FALSE;
        }
        return TRUE;
    }