Skip to content
This repository

Fixing a bug when requesting a non-existing user's profile page #169

Merged
merged 1 commit into from over 2 years ago

2 participants

A.J. David Byrne
A.J.

Fixing a bug where a user would try to lookup a non-existing user's profile and in return would get a empty profile.

Now the server returns a 404 with an error message.

This is related to fixing this issue:
#144

A.J. arajek Fixing a bug where a user would try to lookup a non-existing user's
profile and in return would get a empty profile.
Now the returned page is a 404 with an error message.
bc6ddd0
A.J.

This is a partial fix to this issue:
4clojure#144

David Byrne dbyrne merged commit e251d61 into from
David Byrne
Owner

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 07, 2011
A.J. arajek Fixing a bug where a user would try to lookup a non-existing user's
profile and in return would get a empty profile.
Now the returned page is a 404 with an error message.
bc6ddd0
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 6 additions and 3 deletions. Show diff stats Hide diff stats

  1. +6 3 src/foreclojure/users.clj
9 src/foreclojure/users.clj
@@ -3,7 +3,7 @@
3 3 [clojure.string :as string]
4 4 [sandbar.stateful-session :as session]
5 5 [cheshire.core :as json])
6   - (:use [foreclojure.utils :only [from-mongo row-class rank-class get-user if-user with-user]]
  6 + (:use [foreclojure.utils :only [from-mongo row-class rank-class get-user if-user with-user flash-error ]]
7 7 [foreclojure.template :only [def-page content-page]]
8 8 [foreclojure.ring-utils :only [*http-scheme* static-url]]
9 9 [foreclojure.config :only [config repo-url]]
@@ -164,7 +164,7 @@
164 164 :heading-note [:span#all-users-link]
165 165 :sub-heading (list (format-user-ranking user-ranking)
166 166 [:span.contributor "*"] " "
167   - (link-to repo-url "4clojure contributor"))
  167 + (link-to repo-url "4clojure contributor") [:br])
168 168 :main (generate-user-list top-100 "user-table")})}))
169 169
170 170 ;; TODO: this is snagged from problems.clj but can't be imported due to cyclic dependency, must refactor this out.
@@ -294,7 +294,10 @@
294 294 (defroutes users-routes
295 295 (GET "/users" [] (top-users-page))
296 296 (GET "/users/all" [] (all-users-page))
297   - (GET "/user/:username" [username] (user-profile username))
  297 + (GET "/user/:username" [username]
  298 + (if (nil? (get-user username))
  299 + {:status 404 :headers {"Content-Type" "text/plain"} :body "Error: This user does not exist, nice try though."}
  300 + (user-profile username)))
298 301 (POST "/user/follow/:username" [username] (static-follow-user username true))
299 302 (POST "/user/unfollow/:username" [username] (static-follow-user username false))
300 303 (POST "/rest/user/follow/:username" [username] (rest-follow-user username true))

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.