0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

Add password recovery request page.

This commit is contained in:
Andrey Antukh 2016-05-28 19:06:51 +03:00
parent 8c1dab4ebf
commit 5a59640a36
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
8 changed files with 46 additions and 5 deletions

View file

@ -118,3 +118,27 @@
(if errors
(udf/assign-errors :register errors)
(Register. data))))
;; --- Recovery Request
(defrecord RecoveryRequest [data]
rs/WatchEvent
(-apply-watch [_ state stream]
(letfn [(on-error [{payload :payload}]
(println "on-error" payload)
(->> (:payload payload)
(udf/assign-errors :recovery-request)
(rx/of)))]
(rx/merge
(->> (rp/req :auth/recovery-request data)
(rx/map (constantly ::recovery-requested))
(rx/catch rp/client-error? on-error))
(->> stream
(rx/filter #(= % ::recovery-requested))
(rx/take 1)
(rx/do #(udm/info! (tr "auth.message.recovery-token-sent")))
(rx/map #(udf/clean :recovery-request)))))))
(defn recovery-request
[data]
(RecoveryRequest. data))

View file

@ -44,6 +44,8 @@
"ds.help.circle" "Circle (Ctrl + E)"
"ds.help.line" "Line (Ctrl + L)"
"auth.message.recovery-token-sent" "Password recovery link sent to your inbox."
"settings.profile" "PROFILE"
"settings.password" "PASSWORD"
"settings.notifications" "NOTIFICATIONS"
@ -54,6 +56,7 @@
"errors.api.form.old-password-not-match" "Incorrect old password"
"errors.api.form.email-already-exists" "The email is already in use by other user."
"errors.api.form.username-already-exists" "The username is already in use by other user."
"errors.api.form.user-not-exists" "Username or email does not matches any existing user."
"errors.form.required" "This field is mandatory"
"errors.form.string" "Should be string"
"errors.form.number" "Invalid number"

View file

@ -37,3 +37,10 @@
:method :post
:body data}]
(send! params)))
(defmethod request :auth/recovery-request
[_ data]
(let [params {:url (str url "/auth/recovery")
:method :post
:body data}]
(send! params)))

View file

@ -61,7 +61,7 @@
(def routes
["/" [["auth/login" :auth/login]
["auth/register" :auth/register]
["auth/recover" :auth/recover-password]
["auth/recovery-request" :auth/recovery-request]
["settings/" [["profile" :settings/profile]
["password" :settings/password]

View file

@ -31,7 +31,11 @@
;; --- Constants
(def ^:const +unrestricted+ #{:auth/login :auth/register})
(def ^:const +unrestricted+
#{:auth/login
:auth/register
:auth/recovery-request
:auth/recovery})
(def ^:const restricted? (complement +unrestricted+))
(def route-l
@ -78,6 +82,8 @@
(case location
:auth/login (auth/login-page)
:auth/register (auth/register-page)
:auth/recovery-request (auth/recovery-request-page)
;; :auth/recovery (auth/recovery-page)
:dashboard/projects (dashboard/projects-page)
:dashboard/elements (dashboard/elements-page)
:dashboard/icons (dashboard/icons-page)

View file

@ -6,7 +6,9 @@
(ns uxbox.ui.auth
(:require [uxbox.ui.auth.login :as login]
[uxbox.ui.auth.register :as register]))
[uxbox.ui.auth.register :as register]
[uxbox.ui.auth.recovery :as recovery]))
(def login-page login/login-page)
(def register-page register/register-page)
(def recovery-request-page recovery/recovery-request-page)

View file

@ -71,7 +71,7 @@
:value "Continue"
:type "submit"}]
[:div.login-links
[:a {:on-click #(rt/go :auth/recover-password)} "Forgot your password?"]
[:a {:on-click #(rt/go :auth/recovery-request)} "Forgot your password?"]
[:a {:on-click #(rt/go :auth/register)} "Don't have an account?"]]]]]])))
(defn- login-page-will-mount

View file

@ -23,7 +23,6 @@
[uxbox.ui.mixins :as mx]
[uxbox.util.dom :as dom]))
;; --- Constants
(def form-data