Login with Gitlab

This commit is contained in:
Vitaly Kornilov 2020-08-24 13:24:36 +03:00 committed by Andrey Antukh
parent dcd7e0b3cc
commit cc1353300e
9 changed files with 207 additions and 1 deletions

View file

@ -14,6 +14,7 @@
(def default-language "en")
(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 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

@ -71,6 +71,12 @@
(->> (http/send! {:method :post :uri uri})
(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})
(rx/mapcat handle-response))))
(defmethod mutation :upload-media-object
[id params]
(let [form (js/FormData.)]

View file

@ -40,6 +40,13 @@
(rx/subs (fn [{:keys [redirect-uri] :as rsp}]
(.replace js/location redirect-uri)))))
(defn- login-with-gitlab
[event]
(dom/prevent-default event)
(->> (rp/mutation! :login-with-gitlab {})
(rx/subs (fn [{:keys [redirect-uri] :as rsp}]
(.replace js/location redirect-uri)))))
(mf/defc login-form
[{:keys [locale] :as props}]
(let [error? (mf/use-state false)
@ -113,6 +120,13 @@
{:on-click login-with-google}
"Login with Google"])
(when cfg/gitlab-client-id
[:a.btn-ocean.btn-large.btn-gitlab-auth
{:on-click login-with-gitlab}
[:img.logo
{:src "/images/icons/brand-gitlab.svg"}]
"Login with Gitlab"])
[:div.links.demo
[:div.link-entry
[:span (t locale "auth.create-demo-profile-label") " "]