diff options
| author | sostler <sbostler@gmail.com> | 2010-04-08 05:33:14 -0400 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-04-08 05:33:14 -0400 |
| commit | 956291711de6afb17137160a67ac710be0ace1e1 (patch) | |
| tree | 8ed91989f2418d8b9fba0a277f241ee0ce11c48f | |
| parent | 3bc6dfdbb08028fae24b17ad07d6ccbb06e809cb (diff) | |
Re-added case-insensitive nick check
| -rwxr-xr-x | src/site.clj | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/site.clj b/src/site.clj index ef4e773..3a59264 100755 --- a/src/site.clj +++ b/src/site.clj @@ -104,6 +104,10 @@ (< (count n) 3) "NICK_TOO_SHORT" (not (re-matches nick-regex n)) "NICK_INVALID_CHARS")) +(defn check-nick [nick] + (let [query "SELECT * FROM users WHERE LOWER(nick) = ? LIMIT 1"] + (> (count (do-select [query (s/lower-case nick)])) 0))) + (defn fetch-nick [nick] (let [query "SELECT * FROM users WHERE nick = ? LIMIT 1"] (first (do-select [query nick])))) @@ -328,7 +332,7 @@ hash (params :hash) invalid-nick-reason (is-invalid-nick? nick)] (cond invalid-nick-reason (resp-error invalid-nick-reason) - (fetch-nick nick) (resp-error "NICK_TAKEN") + (check-nick nick) (resp-error "NICK_TAKEN") :else (with-connection *db* (insert-values :users [:nick :hash :email] |
