mirror of
https://github.com/penpot/penpot.git
synced 2025-05-27 21:16:13 +02:00
🐛 Fix corner cases on invitation/signup flows.
This commit is contained in:
parent
784a4f8ecd
commit
4991cae5ad
11 changed files with 223 additions and 149 deletions
|
@ -81,19 +81,19 @@
|
|||
(defmethod mutation :login-with-google
|
||||
[id params]
|
||||
(let [uri (str cfg/public-uri "/api/oauth/google")]
|
||||
(->> (http/send! {:method :post :uri uri})
|
||||
(->> (http/send! {:method :post :uri uri :query params})
|
||||
(rx/mapcat handle-response))))
|
||||
|
||||
(defmethod mutation :login-with-gitlab
|
||||
[id params]
|
||||
(let [uri (str cfg/public-uri "/api/oauth/gitlab")]
|
||||
(->> (http/send! {:method :post :uri uri})
|
||||
(->> (http/send! {:method :post :uri uri :query params})
|
||||
(rx/mapcat handle-response))))
|
||||
|
||||
(defmethod mutation :login-with-github
|
||||
[id params]
|
||||
(let [uri (str cfg/public-uri "/api/oauth/github")]
|
||||
(->> (http/send! {:method :post :uri uri})
|
||||
(->> (http/send! {:method :post :uri uri :query params})
|
||||
(rx/mapcat handle-response))))
|
||||
|
||||
(defmethod mutation :upload-file-media-object
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
;; Copyright (c) 2020-2021 UXBOX Labs SL
|
||||
|
||||
(ns app.main.ui.auth.login
|
||||
(:require
|
||||
|
@ -33,25 +33,25 @@
|
|||
(s/keys :req-un [::email ::password]))
|
||||
|
||||
(defn- login-with-google
|
||||
[event]
|
||||
[event params]
|
||||
(dom/prevent-default event)
|
||||
(->> (rp/mutation! :login-with-google {})
|
||||
(->> (rp/mutation! :login-with-google params)
|
||||
(rx/subs (fn [{:keys [redirect-uri] :as rsp}]
|
||||
(.replace js/location redirect-uri))
|
||||
(fn [{:keys [type] :as error}]
|
||||
(st/emit! (dm/error (tr "errors.google-auth-not-enabled")))))))
|
||||
|
||||
(defn- login-with-gitlab
|
||||
[event]
|
||||
[event params]
|
||||
(dom/prevent-default event)
|
||||
(->> (rp/mutation! :login-with-gitlab {})
|
||||
(->> (rp/mutation! :login-with-gitlab params)
|
||||
(rx/subs (fn [{:keys [redirect-uri] :as rsp}]
|
||||
(.replace js/location redirect-uri)))))
|
||||
|
||||
(defn- login-with-github
|
||||
[event]
|
||||
[event params]
|
||||
(dom/prevent-default event)
|
||||
(->> (rp/mutation! :login-with-github {})
|
||||
(->> (rp/mutation! :login-with-github params)
|
||||
(rx/subs (fn [{:keys [redirect-uri] :as rsp}]
|
||||
(.replace js/location redirect-uri)))))
|
||||
|
||||
|
|
|
@ -81,11 +81,8 @@
|
|||
(mf/use-callback
|
||||
(fn [form data]
|
||||
(reset! submitted? false)
|
||||
(if (and (:is-active data) (:claims data))
|
||||
(let [message (tr "auth.notifications.team-invitation-accepted")]
|
||||
(st/emit! (rt/nav :dashboard-projects {:team-id (get-in data [:claims :team-id])})
|
||||
(du/fetch-profile)
|
||||
(dm/success message)))
|
||||
(if-let [token (:invitation-token data)]
|
||||
(st/emit! (rt/nav :auth-verify-token {} {:token token}))
|
||||
(st/emit! (rt/nav :auth-register-success {} {:email (:email data)})))))
|
||||
|
||||
on-submit
|
||||
|
@ -161,19 +158,19 @@
|
|||
|
||||
(when cfg/google-client-id
|
||||
[:a.btn-ocean.btn-large.btn-google-auth
|
||||
{:on-click login/login-with-google}
|
||||
{:on-click #(login/login-with-google % params)}
|
||||
"Login with Google"])
|
||||
|
||||
(when cfg/gitlab-client-id
|
||||
[:a.btn-ocean.btn-large.btn-gitlab-auth
|
||||
{:on-click login/login-with-gitlab}
|
||||
{:on-click #(login/login-with-gitlab % params)}
|
||||
[:img.logo
|
||||
{:src "/images/icons/brand-gitlab.svg"}]
|
||||
(tr "auth.login-with-gitlab-submit")])
|
||||
|
||||
(when cfg/github-client-id
|
||||
[:a.btn-ocean.btn-large.btn-github-auth
|
||||
{:on-click login/login-with-github}
|
||||
{:on-click #(login/login-with-github % params)}
|
||||
[:img.logo
|
||||
{:src "/images/icons/brand-github.svg"}]
|
||||
(tr "auth.login-with-github-submit")])])
|
||||
|
|
|
@ -58,12 +58,14 @@
|
|||
(dm/success message)))
|
||||
|
||||
:pending
|
||||
(st/emit! (rt/nav :auth-register {} {:token (:token tdata)}))))
|
||||
(let [token (:invitation-token tdata)]
|
||||
(st/emit! (rt/nav :auth-register {} {:invitation-token token})))))
|
||||
|
||||
(defmethod handle-token :default
|
||||
[tdata]
|
||||
(js/console.log "Unhandled token:" (pr-str tdata))
|
||||
(st/emit! (rt/nav :auth-login)))
|
||||
(st/emit!
|
||||
(rt/nav :auth-login)
|
||||
(dm/warn (tr "errors.unexpected-token"))))
|
||||
|
||||
(mf/defc verify-token
|
||||
[{:keys [route] :as props}]
|
||||
|
|
|
@ -18,10 +18,9 @@
|
|||
[app.main.data.modal :as modal]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.forms :refer [input submit-button form]]
|
||||
[app.main.ui.components.forms :as fm]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.forms :as fm]
|
||||
[app.util.i18n :as i18n :refer [t tr]]
|
||||
[app.util.keyboard :as kbd]
|
||||
[app.util.object :as obj]
|
||||
|
@ -90,28 +89,28 @@
|
|||
|
||||
[:div.modal-overlay
|
||||
[:div.modal-container.team-form-modal
|
||||
[:div.modal-header
|
||||
[:div.modal-header-title
|
||||
(if team
|
||||
[:h2 "Rename team"]
|
||||
[:h2 "Create new team"])]
|
||||
[:div.modal-close-button
|
||||
{:on-click (st/emitf (modal/hide))} i/close]]
|
||||
[:& fm/form {:form form
|
||||
:on-submit on-submit}
|
||||
|
||||
[:div.modal-content.generic-form
|
||||
[:form
|
||||
[:& input {:type "text"
|
||||
:form form
|
||||
:name :name
|
||||
:label "Enter new team name:"}]]]
|
||||
[:div.modal-header
|
||||
[:div.modal-header-title
|
||||
(if team
|
||||
[:h2 (tr "labels.rename-team")]
|
||||
[:h2 (tr "labels.create-team")])]
|
||||
[:div.modal-close-button
|
||||
{:on-click (st/emitf (modal/hide))} i/close]]
|
||||
|
||||
[:div.modal-footer
|
||||
[:div.action-buttons
|
||||
[:& submit-button
|
||||
{:form form
|
||||
:on-click on-submit
|
||||
:label (if team
|
||||
"Update team"
|
||||
"Create team")}]]]]]))
|
||||
[:div.modal-content.generic-form
|
||||
[:& fm/input {:type "text"
|
||||
:form form
|
||||
:name :name
|
||||
:label "Enter new team name:"}]]
|
||||
|
||||
[:div.modal-footer
|
||||
[:div.action-buttons
|
||||
[:& fm/submit-button
|
||||
{:label (if team
|
||||
(tr "labels.update-team")
|
||||
(tr "labels.create-team"))}]]]]]]))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue