Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit bc6ddd08582b78fa25a7bc21f83a5a7539f08c17 1 parent 20d8b17
@arajek arajek authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/foreclojure/users.clj
View
9 src/foreclojure/users.clj
@@ -3,7 +3,7 @@
[clojure.string :as string]
[sandbar.stateful-session :as session]
[cheshire.core :as json])
- (:use [foreclojure.utils :only [from-mongo row-class rank-class get-user if-user with-user]]
+ (:use [foreclojure.utils :only [from-mongo row-class rank-class get-user if-user with-user flash-error ]]
[foreclojure.template :only [def-page content-page]]
[foreclojure.ring-utils :only [*http-scheme* static-url]]
[foreclojure.config :only [config repo-url]]
@@ -164,7 +164,7 @@
:heading-note [:span#all-users-link]
:sub-heading (list (format-user-ranking user-ranking)
[:span.contributor "*"] " "
- (link-to repo-url "4clojure contributor"))
+ (link-to repo-url "4clojure contributor") [:br])
:main (generate-user-list top-100 "user-table")})}))
;; TODO: this is snagged from problems.clj but can't be imported due to cyclic dependency, must refactor this out.
@@ -294,7 +294,10 @@
(defroutes users-routes
(GET "/users" [] (top-users-page))
(GET "/users/all" [] (all-users-page))
- (GET "/user/:username" [username] (user-profile username))
+ (GET "/user/:username" [username]
+ (if (nil? (get-user username))
+ {:status 404 :headers {"Content-Type" "text/plain"} :body "Error: This user does not exist, nice try though."}
+ (user-profile username)))
(POST "/user/follow/:username" [username] (static-follow-user username true))
(POST "/user/unfollow/:username" [username] (static-follow-user username false))
(POST "/rest/user/follow/:username" [username] (rest-follow-user username true))
Please sign in to comment.
Something went wrong with that request. Please try again.