Title / Description
Code (defn activate! "An activation_code_created_at column is used to handle expirations. Returns: - nil if activation fails (errors can be retrieved using noir.validation) - the user object if activation succeeds" [activation-code] (if-let [user (find-by-activation-code activation-code)] ; https://github.com/seancorfield/clj-time ; https://github.com/seancorfield/clj-time/blob/master/src/clj_time/core.clj (if (> (time/in-hours (time/interval (:activation_code_created_at user) (time/now))) 1) (vali/set-error :activation_code :expired-activation-code) (update! (:_id user) {:activation_code :$unset :activation_code_created_at :$unset} {:skip-validations true})) (vali/set-error :activation_code :activation-code-not-found)))
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code