Query in database, user authentication