From ee124f1a698551e8307176e8dfdfb04aa6535bae Mon Sep 17 00:00:00 2001 From: sostler Date: Tue, 4 May 2010 00:11:38 -0400 Subject: Added user-accessible pw reset request --- src/site.clj | 4 +++ src/user.clj | 4 +-- static/index.html | 45 ++++++++++++++++----------------- template/req_reset.st | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 26 deletions(-) create mode 100644 template/req_reset.st diff --git a/src/site.clj b/src/site.clj index 7848dcb..d1175d5 100644 --- a/src/site.clj +++ b/src/site.clj @@ -816,6 +816,9 @@ ORDER BY msg_count DESC") ;; Account resets +(defn reset-request-page [session] + (.toString (fetch-template "req_reset" session))) + (defn reset-request! [session {nick :nick}] (if-let [info (fetch-nick nick)] (let [email (info :email) @@ -1004,6 +1007,7 @@ ORDER BY msg_count DESC") (GET "/directory" (directory session 0)) (GET "/directory/:offset" (directory session (maybe-parse-int (params :offset) 0))) + (GET "/reset-request" (reset-request-page session)) (POST "/reset-request" (reset-request! session params)) (GET "/reset" (reset-page session params)) (POST "/reset" (reset-account! session params)) diff --git a/src/user.clj b/src/user.clj index 9d3060f..b948a8f 100644 --- a/src/user.clj +++ b/src/user.clj @@ -37,6 +37,6 @@ "token" token})) (defn valid-reset-link? [nick token ts] - (if-let [info (fetch-nick nick)] + (if-let [info (and nick (fetch-nick nick))] (and (= token (reset-token (info :nick) (info :hash) ts)) - (>= ts (ms-ago (days 2)))))) \ No newline at end of file + (>= ts (ms-ago (days 2)))))) diff --git a/static/index.html b/static/index.html index 3b6e755..cca686b 100755 --- a/static/index.html +++ b/static/index.html @@ -4,34 +4,30 @@ dump.fm - - - - - - - + + + + + + + - - dump.fm - + + +dump.fm @@ -51,7 +47,6 @@ $(document).ready(function(){
-
Click here to Register!
@@ -61,13 +56,15 @@ $(document).ready(function(){
- - -
diff --git a/template/req_reset.st b/template/req_reset.st new file mode 100644 index 0000000..4089298 --- /dev/null +++ b/template/req_reset.st @@ -0,0 +1,69 @@ + + + dump.fm Password Reset + + $head()$ + + + + + $banner()$ +
+ +

Forgot your password?

+
+
+ Enter your nick, and we'll send you an email to reset your password. +
+
+ + +
+ +
+ + -- cgit v1.2.3-70-g09d2