summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordumpfmprod <dumpfmprod@ubuntu.(none)>2010-04-08 05:09:34 -0400
committerdumpfmprod <dumpfmprod@ubuntu.(none)>2010-04-08 05:09:34 -0400
commit25714fb55fdf6fa02721fec35c9105345e87c35b (patch)
treeea05ce849aac99c5cf93a6cb25b7e55f900d2029
parentcfc2525c124d23ff4b76dff03bca005c1d7ba17a (diff)
parent060d0a20fa9d8e1e0c9f9cb5218ef37b46015301 (diff)
Merge branch 'master' of /pichat/repo
-rwxr-xr-xsrc/site.clj4
-rwxr-xr-xstatic/js/register.js91
-rw-r--r--static/register.html7
3 files changed, 12 insertions, 90 deletions
diff --git a/src/site.clj b/src/site.clj
index ef4e773..43bbe7e 100755
--- a/src/site.clj
+++ b/src/site.clj
@@ -105,8 +105,8 @@
(not (re-matches nick-regex n)) "NICK_INVALID_CHARS"))
(defn fetch-nick [nick]
- (let [query "SELECT * FROM users WHERE nick = ? LIMIT 1"]
- (first (do-select [query nick]))))
+ (let [query "SELECT * FROM users WHERE LOWER(nick) = ? LIMIT 1"]
+ (first (do-select [query (s/lower-case nick)]))))
(defn authorize-nick-hash [nick hash]
(let [db-user (fetch-nick nick)]
diff --git a/static/js/register.js b/static/js/register.js
index 31d32e5..30e221f 100755
--- a/static/js/register.js
+++ b/static/js/register.js
@@ -1,94 +1,24 @@
-function validateNick(n) {
- if (n.length <= 2) {
- return "BAD_NICK_LENGTH";
- }
-}
-
-
-function submitRegistration() {
- var nick = $('#nickInput').val();
- var email = $('#emailInput').val();
- var password = $('#passwordInput').val() || "";function validateNick(n) {
- if (n.length <= 2) {
- return "BAD_NICK_LENGTH";
- }
-}
-
-
function submitRegistration() {
var nick = $('#nickInput').val();
var email = $('#emailInput').val();
var password = $('#passwordInput').val() || "";
-
+ var password2 = $('#passwordInput2').val() || "";
if (nick.length < 3 || nick.length > 12) {
alert("Nicks must be between 3 and 12 characters long.");
return;
- } else if (password.length < 5) {
- alert("Password must be at least 5 characters long.");
- return;
}
-
-
- var hash = hex_sha1(nick + '$' + password + '$dumpfm');
- var onSuccess = function() {
- if (typeof pageTracker !== 'undefined') {
- pageTracker._trackEvent('User', 'Register', nick);
- }
- location.href = "/";
- };
-
- var onError = function(resp) {
- var respText = resp.responseText ? resp.responseText.trim() : false;
- if (respText == 'NICK_TAKEN') {
- alert("That nick is already taken! Please choose another.");
- } else if (respText == 'NICK_INVALID_CHARS') {
- alert("Nicks can only contain letters and numbers.");
- } else {
- alert("Unable to register!");
- }
- };
-
- $.ajax({
- type: 'POST',
- timeout: 5000,
- url: 'submit-registration',
- data: {'nick': nick, 'email': email, 'hash': hash },
- cache: false,
- dataType: 'json',
- success: onSuccess,
- error: onError
-
- });
-}
-
-function initRegister() {
- $('#submit').click(submitRegistration);
-}
-
-function handleMsgError(resp) {
- var respText = resp.responseText ? resp.responseText.trim() : false;
- if (respText == 'UNKNOWN_USER') {
- alert("Can't send message! Please login.");
- } else if (respText) {
- alert("Cannot send message! (" + respText + ")");
- } else {
- alert("Cannot send message!");
+ if (password != password2) {
+ alert("Passwords must match!");
+ return;
}
-}
-
- if (nick.length < 3 || nick.length > 12) {
- alert("Nicks must be between 3 and 12 characters long.");
- return;
- } else if (password.length < 5) {
+ if (password.length < 5) {
alert("Password must be at least 5 characters long.");
return;
}
-
-
var hash = hex_sha1(nick + '$' + password + '$dumpfm');
var onSuccess = function() {
if (typeof pageTracker !== 'undefined') {
@@ -123,15 +53,4 @@ function handleMsgError(resp) {
function initRegister() {
$('#submit').click(submitRegistration);
-}
-
-function handleMsgError(resp) {
- var respText = resp.responseText ? resp.responseText.trim() : false;
- if (respText == 'UNKNOWN_USER') {
- alert("Can't send message! Please login.");
- } else if (respText) {
- alert("Cannot send message! (" + respText + ")");
- } else {
- alert("Cannot send message!");
- }
} \ No newline at end of file
diff --git a/static/register.html b/static/register.html
index a758e66..f7c7163 100644
--- a/static/register.html
+++ b/static/register.html
@@ -39,13 +39,16 @@
<br />
<span>password</span>
- <input type="password"class="field" id="passwordInput" />
+ <input type="password" class="field" id="passwordInput" />
+ <br />
+ <span>repeat password</span>
+ <input type="password" class="field" id="passwordInput2" />
+
</h1>
<h1><span>email</span>
<input type="text" class="field"id="emailInput" />
</h1>
-
<h1><br />