(module special-prefs mzscheme (require "hwikireq.scm") (require "page.scm") (require "config.scm") (require "context.scm") (require "users.scm") (require "template.scm") (provide special:prefs) (def-class (this (special:prefs context)) (supers (page-base)) (private (define _template (template 'context context 'name "admin")) ) (public (define (get-template) _template) (define (css) (-> _template css)) (define (title) (_ "HWiki Preferences - Change Password")) (define (create-html) (if (not (-> context logged-in?)) (-> supers not-autorized context `(p ,(_ "You must login to be able to set your preferences"))) (let ((P (page context (-> context from-where)))) (debug "create-html:P:" (-> P name)) (let ((T (-> P get-template))) (let ((form (lambda (url) (adjust-timeout! (form-timeout)) (-> context make-response/xhtml `(html ,(-> supers create-header context) (body (div ((class "prefs")) (h1 ,(_ "Change Password")) (form ((name "prefs") (action ,url) (method "post")) (table (tr (td ,(_ "Password:") (td (input ((type "password") (name "pass1") (size "40")))))) (tr (td ,(_ "Password again:") (td (input ((type "password") (name "pass2") (size "40")))))) (tr (td ((class "tdbutton")) (input ((type "submit") (name "submit") (value ,(_ "cancel"))))) (td ((class "tdbutton")) (input ((type "submit") (name "submit") (value ,(_ "ok")))))))) ))))))) (let ((bindings (request-bindings (send/suspend form)))) (let ((action (extract-binding/single 'submit bindings)) (pass1 (extract-binding/single 'pass1 bindings)) (pass2 (extract-binding/single 'pass2 bindings))) (if (string-ci=? action (_ "ok")) (if (string=? pass1 pass2) (let ((U (users context))) (-> U set-pass (-> context user) pass1) (-> context to-from-where)) (-> this do-error (_ "Passwords differ from each other") create-html)) (-> context to-from-where))))))) )) ) (constructor (-> supers special!) ) ) (register-page "special:prefs" special:prefs) )