Repository: bookwyrm-social/bookwyrm

Issue:
not able to search for a user un-logged in
No option to search for a user without being logged in even though it says books or users in the non logged in search field 

**Screenshots**
![B1B1BF6E-685C-4981-AC1C-FD393FC5DCDA](https://user-images.githubusercontent.com/7890201/134020800-b1b6b514-35a4-4afa-829f-652d6a7028ae.png)
![C1878A19-8A29-48BC-9993-3E105F743301](https://user-images.githubusercontent.com/7890201/134020810-e0d4dfc0-ce11-44e8-b01c-f939d8146b80.png)

**Instance**
bookwyrm.social

---

**Desktop (please complete the following information):**
iOS 12, Firefox



Discussion:
Thank you -- either that language should change, or logged out user search should be enabled. I made user search logged-in-only out of a general sense of user privacy, but I'd be interested to know if that's more of a hassle than a benefit.
I personally like it the way it works currently, it makes sense for small communities where members are trusted over non-members.

On the other hand, I can certainly see the benefits for large, or more open instances, where being able to find someone is preferred.

As a compromise, I can imagine a global and a per user setting to override it. This way, administrator(s) could decide whether users show up in public searches, while users could decide to accept this or go with the opposite respectively.
For now, since no one was expressed a desire to search for users while logged out, I'll just change the wording in the search box. But it's open to reevaluate in the future :)
Thanks for the speedy response! I personally like being able to search an instance to see if a friend is there before signing up. If someone tells me “I’m AnaBanana on bookworm” in person, and I ask, what instance, and they respond “huh? What’s an instance” I would like to be able to solve this myself. Even if I have an account on one bookwyrm instance I would need to go try to find them on another. This is actually an issue I have had many times on the fediverse with mastodon and such, people signing up and using it but not understanding the concept that their identity is attached to something else. Anyway I vote for @Flameborn’s compromise solution. I guess I could open another issue for that since this one has been closed for changing the wording. 
Thank you! Your use case makes a lot of sense, and I'm totally happy to re-open this

Resolving patch:
diff --git a/bookwyrm/views/search.py b/bookwyrm/views/search.py
--- a/bookwyrm/views/search.py
+++ b/bookwyrm/views/search.py
@@ -91,18 +91,15 @@ def book_search(request):
 
 
 def user_search(request):
-    """cool kids members only user search"""
+    """user search: search for a user"""
     viewer = request.user
     query = request.GET.get("q")
     query = query.strip()
     data = {"type": "user", "query": query}
-    # logged out viewers can't search users
-    if not viewer.is_authenticated:
-        return TemplateResponse(request, "search/user.html", data)
 
     # use webfinger for mastodon style account@domain.com username to load the user if
     # they don't exist locally (handle_remote_webfinger will check the db)
-    if re.match(regex.FULL_USERNAME, query):
+    if re.match(regex.FULL_USERNAME, query) and viewer.is_authenticated:
         handle_remote_webfinger(query)
 
     results = (
@@ -118,6 +115,11 @@ def user_search(request):
         )
         .order_by("-similarity")
     )
+
+    # don't expose remote users
+    if not viewer.is_authenticated:
+        results = results.filter(local=True)
+
     paginated = Paginator(results, PAGE_LENGTH)
     page = paginated.get_page(request.GET.get("page"))
     data["results"] = page


Test patch:
diff --git a/bookwyrm/tests/views/test_search.py b/bookwyrm/tests/views/test_search.py
--- a/bookwyrm/tests/views/test_search.py
+++ b/bookwyrm/tests/views/test_search.py
@@ -156,7 +156,7 @@ def test_search_users_logged_out(self):
         response = view(request)
 
         validate_html(response.render())
-        self.assertFalse("results" in response.context_data)
+        self.assertTrue("results" in response.context_data)
 
     def test_search_lists(self):
         """searches remote connectors"""