Check if the user exists in database
177293
function isAuthenticated(username, password) {

    var userIndex = userdb.users.findIndex(function (user) {
        return (user.name === username && user.password === password);
    });

    return userIndex != -1;
}
52213
private void loadUser(String username)
    {
        try
        {
            if (null==_con)
                connectDatabase();
            
            if (null==_con)
                throw new SQLException("Can't connect to database");
            
            PreparedStatement stat = _con.prepareStatement(_userSql);
            stat.setObject(1, username);
            ResultSet rs = stat.executeQuery();
    
            if (rs.next())
            {
                Object key = rs.getObject(_userTableKey);
                put(username, rs.getString(_userTablePasswordField));
                stat.close();
                
                stat = _con.prepareStatement(_roleSql);
                stat.setObject(1, key);
                rs = stat.executeQuery();

                while (rs.next())
                    addUserToRole(username, rs.getString(_roleTableRoleField));
                
                stat.close();
            }
        }
        catch (SQLException e)
        {
            log.warn("UserRealm " + getName()
                      + " could not load user information from database", e);
            connectDatabase();
        }
    }
956460
protected boolean userAlreadyExists(String username) {

        if (m_user != null) {
            return false;
        }
        CmsUser user = null;
        try {
            user = m_cms.readUser(m_ou.getValue() + username);
        } catch (CmsException e) {
            return false;
        }

        return user != null;

    }
1178923
def exists(project, credentials):
        """"""
        user, oauth_access_token = parsecredentials(credentials) #pylint: disable=unused-variable
        printdebug("Checking if project " + project + " exists for " + user)
        return os.path.isdir(Project.path(project, user))
966098
def does_row_exist(self, table: str, field: str, value: Any) -> bool:
        """"""
        sql = ("SELECT COUNT(*) FROM " + self.delimit(table) +
               " WHERE " + self.delimit(field) + "=?")
        row = self.fetchone(sql, value)
        return True if row[0] >= 1 else False
411043
def check_user(self, user_id):
        

        if self.hidden == 'N':
            return True

        for owner in self.owners:
            if int(owner.user_id) == int(user_id):
                if owner.view == 'Y':
                    return True
        return False
243545
def find_by_username(self, username):
        """"""
        data = (db.select(self.table).select('username', 'email', 'real_name',
                                             'password', 'bio', 'status', 'role', 'uid').
                condition('username', username).execute()
                )
        if data:
            return self.load(data[0], self.model)
758541
def delete_database_user(self, username):
        """"""
        url = "db/{0}/users/{1}".format(self._database, username)

        self.request(
            url=url,
            method='DELETE',
            expected_response_code=200
        )

        return True
201179
def grant_exists(grant,
                 database,
                 user,
                 host='localhost',
                 grant_option=False,
                 escape=True,
                 **connection_args):
    '''
    
    '''

    server_version = salt.utils.data.decode(version(**connection_args))
    if not server_version:
        last_err = __context__['mysql.error']
        err = 'MySQL Error: Unable to fetch current server version. Last error was: "{}"'.format(last_err)
        log.error(err)
        return False
    if 'ALL' in grant:
        if salt.utils.versions.version_cmp(server_version, '8.0') >= 0 and \
           'MariaDB' not in server_version:
            grant = ','.join([i for i in __all_privileges__])
        else:
            grant = 'ALL PRIVILEGES'

    try:
        target = __grant_generate(
            grant, database, user, host, grant_option, escape
        )
    except Exception:
        log.error('Error during grant generation.')
        return False

    grants = user_grants(user, host, **connection_args)

    if grants is False:
        log.error('Grant does not exist or may not be ordered properly. In some cases, '
                  'this could also indicate a connection error. Check your configuration.')
        return False

    # Combine grants that match the same database
    _grants = {}
    for grant in grants:
        grant_token = _grant_to_tokens(grant)
        if grant_token['database'] not in _grants:
            _grants[grant_token['database']] = {'user': grant_token['user'],
                                                'database': grant_token['database'],
                                                'host': grant_token['host'],
                                                'grant': grant_token['grant']}
        else:
            _grants[grant_token['database']]['grant'].extend(grant_token['grant'])

    target_tokens = _grant_to_tokens(target)
    for database, grant_tokens in _grants.items():
        try:
            _grant_tokens = {}
            _target_tokens = {}

            _grant_matches = [True if i in grant_tokens['grant']
                              else False for i in target_tokens['grant']]

            for item in ['user', 'database', 'host']:
                _grant_tokens[item] = grant_tokens[item].replace('"', '').replace('\\', '').replace('`', '')
                _target_tokens[item] = target_tokens[item].replace('"', '').replace('\\', '').replace('`', '')

            if _grant_tokens['user'] == _target_tokens['user'] and \
                    _grant_tokens['database'] == _target_tokens['database'] and \
                    _grant_tokens['host'] == _target_tokens['host'] and \
                    all(_grant_matches):
                return True
            else:
                log.debug('grants mismatch \'%s\'<>\'%s\'', grant_tokens, target_tokens)

        except Exception as exc:  # Fallback to strict parsing
            log.exception(exc)
            if grants is not False and target in grants:
                log.debug('Grant exists.')
                return True

    log.debug('Grant does not exist, or is perhaps not ordered properly?')
    return False
187391
private function checkUserInfo() : void
    {
        foreach ($this->user->getAttributes() as $key => $value) {
            $this->{$key} = $value;
        }
    }
1159356
public static function _exists ($params, &$db = FALSE)
	{
	
		if (!is_array ($params))
		{
			$params	= array (
				'where'	=> array (
					array (static::$pk, $params)
				)
			);
		}
		
		return self::_count ($params, $db) > 0;
		
	}
524168
def user_exists(username):
    """"""
    try:
        pwd.getpwnam(username)
        user_exists = True
    except KeyError:
        user_exists = False
    return user_exists
1302219
def _check_object_exists(self):
        
        if not DB.get_keys(self.key):
            raise KeyError("Object with key '{}' not exist".format(self.key))
1046473
def get_user_if_exists(strategy, details, user=None, *args, **kwargs):
    """"""
    if user:
        return {'is_new': False}
    try:
        username = details.get('username')

        # Return the user if it exists
        return {
            'is_new': False,
            'user': User.objects.get(username=username)
        }
    except User.DoesNotExist:
        # Fall to the default return value
        pass

    # Nothing to return since we don't have a user
    return {}
236197
def get_user_by_name(uname,**kwargs):
    
    try:
        user_i = db.DBSession.query(User).filter(User.username==uname).one()
        return user_i
    except NoResultFound:
        return None
627213
protected function perform_check()
	{
		// fetch the username and login hash from the session
		$username    = \Session::get('username');
		$login_hash  = \Session::get('login_hash');

		// only worth checking if there's both a username and login-hash
		if ( ! empty($username) and ! empty($login_hash))
		{
			if (is_null($this->user) or ($this->user['username'] != $username and $this->user != static::$guest_login))
			{
				$this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
					->where('username', '=', $username)
					->from(\Config::get('simpleauth.table_name'))
					->execute(\Config::get('simpleauth.db_connection'))->current();
			}

			// return true when login was verified, and either the hash matches or multiple logins are allowed
			if ($this->user and (\Config::get('simpleauth.multiple_logins', false) or $this->user['login_hash'] === $login_hash))
			{
				return true;
			}
		}

		// not logged in, do we have remember-me active and a stored user_id?
		elseif (static::$remember_me and $user_id = static::$remember_me->get('user_id', null))
		{
			return $this->force_login($user_id);
		}

		// no valid login when still here, ensure empty session and optionally set guest_login
		$this->user = \Config::get('simpleauth.guest_login', true) ? static::$guest_login : false;
		\Session::delete('username');
		\Session::delete('login_hash');

		return false;
	}
474219
def exists(self, primary_key):
        
        '''
            
        '''
        
        select_statement = self.table.select(self.table).where(self.table.c.id==primary_key)
        record_object = self.session.execute(select_statement).first()
        if record_object:
            return True
        return False