🎉 Add github auth provider.

This commit is contained in:
Vitaly Kornilov 2021-01-06 11:54:37 +01:00 committed by Alonso Torres
parent 63cc6aecaf
commit f3b5b07796
9 changed files with 62 additions and 3 deletions

View file

@ -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")

View file

@ -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.)]

View file

@ -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") " "]