summaryrefslogtreecommitdiff
path: root/src/admin.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/admin.clj')
-rw-r--r--src/admin.clj22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/admin.clj b/src/admin.clj
index f0b6453..76e690a 100644
--- a/src/admin.clj
+++ b/src/admin.clj
@@ -4,6 +4,7 @@
(:use compojure
email
scheduled-agent
+ user
utils))
;; Muting
@@ -105,9 +106,6 @@ WHERE mute_id = ?
AND cancelled = false
")
-(defn- assert-update [res ok err]
- (if (zero? (first res)) err ok))
-
(defn cancel-mute! [mute-id admin-id]
(let [mute (fetch-mute mute-id)
active (nor (:expired mute) (:cancelled mute))
@@ -152,6 +150,9 @@ AND cancelled = false
;; Debug Page
+(defn error-header [& text]
+ (html [:h2 {"color" "red"} text]))
+
(defn exception-to-string [e]
(let [sw (java.io.StringWriter.)
pw (java.io.PrintWriter. sw)]
@@ -171,6 +172,7 @@ AND cancelled = false
st (fetch-template "debug" session)]
(.setAttribute st "flash" (:msg flash))
(.setAttribute st "mailtemps" (lookup-templates "template/mail" "welcome"))
+ (.setAttribute st "resettemps" (lookup-templates "template/mail" "reset"))
(.toString st))))
(defn debug-reg-email [session params]
@@ -179,14 +181,22 @@ AND cancelled = false
(params :template))
(str "Sent registration mail to " (params :to)))
-(defn debug-reset-email [session params]
- )
+(defn debug-reset-email [session {nick :nick to :to template :template}]
+ (if-let [info (fetch-nick nick)]
+ (let [nick (info :nick)
+ hash (info :hash)
+ ts (System/currentTimeMillis)
+ token (reset-token nick hash ts)
+ link (reset-link nick token ts)]
+ (do (send-reset-email nick to link template)
+ (str "Send reset email to " to)))
+ (error-header "Unknown user " nick)))
(def *debug-action-map* {"regemail" debug-reg-email
"resetemail" debug-reset-email})
(defn format-unknown-action [action]
- (html [:h2 {"color" "red"} ["Unknown action " action]]))
+ (error-header "Unknown action " action))
(defn format-debug-exception [action e]
(html