mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
✨ Don't send emails on recovery password on not verified profile.
And show proper message to the user saying that the profile need to be verfied before proceed.
This commit is contained in:
parent
992a8e9aef
commit
687f7ddf64
4 changed files with 55 additions and 29 deletions
|
@ -403,11 +403,14 @@
|
|||
:name (:fullname profile)}))]
|
||||
|
||||
(db/with-atomic [conn pool]
|
||||
(some->> email
|
||||
(profile/retrieve-profile-data-by-email conn)
|
||||
(create-recovery-token)
|
||||
(send-email-notification conn))
|
||||
nil)))
|
||||
(when-let [profile (profile/retrieve-profile-data-by-email conn email)]
|
||||
(when-not (:is-active profile)
|
||||
(ex/raise :type :validation
|
||||
:code :profile-not-verified
|
||||
:hint "the user need to validate profile before recover password"))
|
||||
(->> profile
|
||||
(create-recovery-token)
|
||||
(send-email-notification conn))))))
|
||||
|
||||
|
||||
;; --- Mutation: Recover Profile
|
||||
|
|
|
@ -173,6 +173,12 @@
|
|||
"es" : "Introduce la nueva contraseña"
|
||||
}
|
||||
},
|
||||
"auth.notifications.profile-not-verified": {
|
||||
"translations": {
|
||||
"en": "Profile is not verified, please verify profile before continue.",
|
||||
"es": "El perfil aun no ha sido validado, porfavor valide el perfil antes de continuar."
|
||||
}
|
||||
},
|
||||
"auth.notifications.invalid-token-error" : {
|
||||
"used-in" : [ "src/app/main/ui/auth/recovery.cljs:47" ],
|
||||
"translations" : {
|
||||
|
|
|
@ -184,10 +184,7 @@
|
|||
|
||||
(->> (rp/mutation :request-profile-recovery data)
|
||||
(rx/tap on-success)
|
||||
(rx/catch (fn [err]
|
||||
(on-error err)
|
||||
(rx/empty))))))))
|
||||
|
||||
(rx/catch on-error))))))
|
||||
|
||||
;; --- Recovery (Password)
|
||||
|
||||
|
|
|
@ -20,49 +20,69 @@
|
|||
[app.util.router :as rt]
|
||||
[cljs.spec.alpha :as s]
|
||||
[cuerdas.core :as str]
|
||||
[beicon.core :as rx]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(s/def ::email ::us/email)
|
||||
(s/def ::recovery-request-form (s/keys :req-un [::email]))
|
||||
|
||||
(defn- on-success
|
||||
[]
|
||||
(st/emit! (dm/info (tr "auth.notifications.recovery-token-sent"))
|
||||
(rt/nav :auth-login)))
|
||||
|
||||
(defn- on-submit
|
||||
[form event]
|
||||
(let [params (with-meta (:clean-data @form)
|
||||
{:on-success on-success})]
|
||||
(st/emit! (uda/request-profile-recovery params))))
|
||||
|
||||
(mf/defc recovery-form
|
||||
[{:keys [locale] :as props}]
|
||||
[]
|
||||
(let [form (fm/use-form :spec ::recovery-request-form
|
||||
:initial {})]
|
||||
:initial {})
|
||||
|
||||
submitted (mf/use-state false)
|
||||
|
||||
on-error
|
||||
(mf/use-callback
|
||||
(fn [{:keys [code] :as error}]
|
||||
(reset! submitted false)
|
||||
(if (= code :profile-not-verified)
|
||||
(rx/of (dm/error (tr "auth.notifications.profile-not-verified")
|
||||
{:timeout nil}))
|
||||
|
||||
(rx/throw error))))
|
||||
|
||||
on-success
|
||||
(mf/use-callback
|
||||
(fn []
|
||||
(reset! submitted false)
|
||||
(st/emit! (dm/info (tr "auth.notifications.recovery-token-sent"))
|
||||
(rt/nav :auth-login))))
|
||||
|
||||
on-submit
|
||||
(mf/use-callback
|
||||
(fn []
|
||||
(reset! submitted true)
|
||||
(->> (with-meta (:clean-data @form)
|
||||
{:on-success on-success
|
||||
:on-error on-error})
|
||||
(uda/request-profile-recovery)
|
||||
(st/emit!))))]
|
||||
|
||||
[:& fm/form {:on-submit on-submit
|
||||
:form form}
|
||||
[:div.fields-row
|
||||
[:& fm/input {:name :email
|
||||
:label (t locale "auth.email")
|
||||
:label (tr "auth.email")
|
||||
:help-icon i/at
|
||||
:type "text"}]]
|
||||
|
||||
[:& fm/submit-button
|
||||
{:label (t locale "auth.recovery-request-submit")}]]))
|
||||
{:label (tr "auth.recovery-request-submit")}]]))
|
||||
|
||||
|
||||
;; --- Recovery Request Page
|
||||
|
||||
(mf/defc recovery-request-page
|
||||
[{:keys [locale] :as props}]
|
||||
[]
|
||||
[:section.generic-form
|
||||
[:div.form-container
|
||||
[:h1 (t locale "auth.recovery-request-title")]
|
||||
[:div.subtitle (t locale "auth.recovery-request-subtitle")]
|
||||
[:& recovery-form {:locale locale}]
|
||||
[:h1 (tr "auth.recovery-request-title")]
|
||||
[:div.subtitle (tr "auth.recovery-request-subtitle")]
|
||||
[:& recovery-form]
|
||||
|
||||
[:div.links
|
||||
[:div.link-entry
|
||||
[:a {:on-click #(st/emit! (rt/nav :auth-login))}
|
||||
(t locale "auth.go-back-to-login")]]]]])
|
||||
(tr "auth.go-back-to-login")]]]]])
|
||||
|
|
Loading…
Add table
Reference in a new issue