mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 03:02:28 +02:00
🎉 Add github auth provider.
This commit is contained in:
parent
63cc6aecaf
commit
f3b5b07796
9 changed files with 62 additions and 3 deletions
|
@ -69,6 +69,7 @@
|
|||
(def demo-warning (obj/get global "appDemoWarning" false))
|
||||
(def google-client-id (obj/get global "appGoogleClientID" nil))
|
||||
(def gitlab-client-id (obj/get global "appGitlabClientID" nil))
|
||||
(def github-client-id (obj/get global "appGithubClientID" nil))
|
||||
(def login-with-ldap (obj/get global "appLoginWithLDAP" false))
|
||||
(def worker-uri (obj/get global "appWorkerURI" "/js/worker.js"))
|
||||
(def public-uri (or (obj/get global "appPublicURI")
|
||||
|
|
|
@ -91,6 +91,12 @@
|
|||
(->> (http/send! {:method :post :uri uri})
|
||||
(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})
|
||||
(rx/mapcat handle-response))))
|
||||
|
||||
(defmethod mutation :upload-file-media-object
|
||||
[id params]
|
||||
(let [form (js/FormData.)]
|
||||
|
|
|
@ -46,6 +46,13 @@
|
|||
(rx/subs (fn [{:keys [redirect-uri] :as rsp}]
|
||||
(.replace js/location redirect-uri)))))
|
||||
|
||||
(defn- login-with-github
|
||||
[event]
|
||||
(dom/prevent-default event)
|
||||
(->> (rp/mutation! :login-with-github {})
|
||||
(rx/subs (fn [{:keys [redirect-uri] :as rsp}]
|
||||
(.replace js/location redirect-uri)))))
|
||||
|
||||
(mf/defc login-form
|
||||
[]
|
||||
(let [error? (mf/use-state false)
|
||||
|
@ -138,6 +145,13 @@
|
|||
{: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-with-github}
|
||||
[:img.logo
|
||||
{:src "/images/icons/brand-github.svg"}]
|
||||
(tr "auth.login-with-github-submit")])
|
||||
|
||||
[:div.links.demo
|
||||
[:div.link-entry
|
||||
[:span (tr "auth.create-demo-profile") " "]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue