Improve email verify threshold

This commit is contained in:
Alejandro Alonso 2024-06-12 11:52:59 +02:00 committed by Andrey Antukh
parent 82a5754923
commit bbd9207191
2 changed files with 10 additions and 7 deletions

View file

@ -87,7 +87,10 @@
:ldap-attrs-fullname "cn" :ldap-attrs-fullname "cn"
;; a server prop key where initial project is stored. ;; a server prop key where initial project is stored.
:initial-project-skey "initial-project"}) :initial-project-skey "initial-project"
;; time to avoid email sending after profile modification
:email-verify-threshold "15m"})
(s/def ::default-rpc-rlimit ::us/vector-of-strings) (s/def ::default-rpc-rlimit ::us/vector-of-strings)
(s/def ::rpc-rlimit-config ::fs/path) (s/def ::rpc-rlimit-config ::fs/path)
@ -213,6 +216,7 @@
(s/def ::telemetry-uri ::us/string) (s/def ::telemetry-uri ::us/string)
(s/def ::telemetry-with-taiga ::us/boolean) (s/def ::telemetry-with-taiga ::us/boolean)
(s/def ::tenant ::us/string) (s/def ::tenant ::us/string)
(s/def ::email-verify-threshold ::dt/duration)
(s/def ::config (s/def ::config
(s/keys :opt-un [::secret-key (s/keys :opt-un [::secret-key
@ -334,7 +338,8 @@
::telemetry-uri ::telemetry-uri
::telemetry-referer ::telemetry-referer
::telemetry-with-taiga ::telemetry-with-taiga
::tenant])) ::tenant
::email-verify-threshold]))
(def default-flags (def default-flags
[:enable-backend-api-doc [:enable-backend-api-doc

View file

@ -38,13 +38,11 @@
(def schema:token (def schema:token
[::sm/word-string {:max 6000}]) [::sm/word-string {:max 6000}])
(def ^:private default-verify-threshold
(dt/duration "15m"))
(defn- elapsed-verify-threshold? (defn- elapsed-verify-threshold?
[profile] [profile]
(let [elapsed (dt/diff (:modified-at profile) (dt/now))] (let [elapsed (dt/diff (:modified-at profile) (dt/now))
(pos? (compare elapsed default-verify-threshold)))) verify-threshold (cf/get :email-verify-threshold)]
(pos? (compare elapsed verify-threshold))))
;; ---- COMMAND: login with password ;; ---- COMMAND: login with password