Browse Source

feat(OAuth): add google login

defclass 5 years ago
parent
commit
ebfda9db8b

+ 11 - 1
src/main/frontend/components/header.cljs

@@ -159,7 +159,17 @@
           {:href "/login/github"
            :on-click (fn []
                        (storage/remove :git/current-repo))}
-          (t :login-github)])
+          (t :login-github)]
+
+         )
+
+       (when (and (not logged?)
+               (not config/publishing?))
+         [:a.text-sm.font-medium.login.opacity-70.hover:opacity-100
+          {:href "/login/google"
+           :on-click (fn []
+                       (storage/remove :git/current-repo))}
+          (t :login-google)])
 
        (repo/sync-status)
 

+ 2 - 2
src/main/frontend/components/home.cljs

@@ -3,5 +3,5 @@
             [frontend.components.sidebar :as sidebar]))
 
 (rum/defc home
-  []
-  (sidebar/main-content))
+  [args]
+  (sidebar/main-content args))

+ 17 - 4
src/main/frontend/components/sidebar.cljs

@@ -28,7 +28,8 @@
             [goog.object :as gobj]
             [frontend.context.i18n :as i18n]
             [reitit.frontend.easy :as rfe]
-            [goog.dom :as gdom]))
+            [goog.dom :as gdom]
+            [frontend.handler.web.nfs :as nfs-handler]))
 
 (defn nav-item
   [title href svg-d active? close-modal-fn]
@@ -143,6 +144,7 @@
 
 (defonce sidebar-inited? (atom false))
 ;; TODO: simplify logic
+
 (rum/defc main-content < rum/reactive db-mixins/query
   {:init (fn [state]
            (when-not @sidebar-inited?
@@ -161,8 +163,10 @@
                        (state/sidebar-add-block! current-repo db-id block-type nil))))
                  (reset! sidebar-inited? true))))
            state)}
-  []
-  (let [today (state/sub :today)
+  [args]
+  (let [query (get-in args [:parameters :query])
+        login-source (:login_source query)
+        today (state/sub :today)
         cloning? (state/sub :repo/cloning?)
         default-home (get-default-home-if-valid)
         importing-to-db? (state/sub :repo/importing-to-db?)
@@ -205,7 +209,16 @@
          (journal/journals latest-journals)
 
          (and logged? (empty? (:repos me)))
-         (widgets/add-repo)
+         (case login-source
+           "google"
+           (if-not (nfs-handler/supported?)
+             [:div (t :help/select-nfs-browser)]
+             [:div (t :help/open-top-right-open-button)])
+
+           "github"
+           (widgets/add-repo)
+
+           (widgets/add-repo))
 
          ;; FIXME: why will this happen?
          :else

+ 15 - 0
src/main/frontend/dicts.cljs

@@ -148,6 +148,8 @@ title: How to take dummy notes?
         :help/move-block-down "Move Block Down"
         :help/create-new-block "Create New Block"
         :help/new-line-in-block "New Line in Block"
+        :help/open-top-right-open-button "Please click the top right 'Open' button to open local directory."
+        :help/select-nfs-browser "Please use another browser (like latest chrome) which support NFS feature to open local directory."
         :undo "Undo"
         :redo "Redo"
         :help/zoom-in "Zoom In"
@@ -331,6 +333,7 @@ title: How to take dummy notes?
         :parsing-files "Parsing files"
         :loading-files "Loading files"
         :login-github "Login with Github"
+        :login-google "Login with Google"
         :go-to "Go to "
         :or "or"
         :download "Download"
@@ -366,6 +369,8 @@ title: How to take dummy notes?
         :help/move-block-down "Déplacer un bloc en dessous"
         :help/create-new-block "Créer un nouveau bloc"
         :help/new-line-in-block "Aller à la ligne dans un bloc"
+        :help/open-top-right-open-button "Please click the top right 'Open' button to open local directory."
+        :help/select-nfs-browser "Please use another browser (like latest chrome) which support NFS feature to open local directory."
         :undo "Annuler"
         :redo "Redo"
         :help/zoom-in "Zoomer"
@@ -543,6 +548,7 @@ title: How to take dummy notes?
         :parsing-files "Analyse des fichiers"
         :loading-files "Chargement des fichiers"
         :login-github "S'authentifier avec Github"
+        :login-google "S'authentifier avec Google"
         :go-to "Aller à "
         :or "ou"
         :download "Télécharger"
@@ -623,6 +629,8 @@ title: How to take dummy notes?
            :help/move-block-down "向下移动块"
            :help/create-new-block "创建块"
            :help/new-line-in-block "块中新建行"
+           :help/open-top-right-open-button "请点击右上角的 Open 来打开本地文件夹."
+           :help/select-nfs-browser "请选择支持nfs的浏览来使用logseq本地文件夹功能, 如最新的Chrome浏览器."
            :undo "撤销"
            :redo "重做"
            :help/zoom-in "聚焦"
@@ -805,6 +813,7 @@ title: How to take dummy notes?
            :parsing-files "正在解析文件"
            :loading-files "正在加载文件"
            :login-github "用 Github 登录"
+           :login-google "用 Google 登录"
            :go-to "转到"
            :or "或"
            :download "下载"
@@ -887,6 +896,8 @@ title: How to take dummy notes?
              :help/move-block-down "向下移動塊"
              :help/create-new-block "創建塊"
              :help/new-line-in-block "塊中新建行"
+             :help/open-top-right-open-button "Please click the top right 'Open' button to open local directory."
+             :help/select-nfs-browser "Please use another browser (like latest chrome) which support NFS feature to open local directory."
              :undo "撤銷"
              :redo "重做"
              :help/zoom-in "聚焦"
@@ -1060,6 +1071,7 @@ title: How to take dummy notes?
              :parsing-files "正在解析文件"
              :loading-files "正在加載文件"
              :login-github "用 Github 登錄"
+             :login-google "用 Google 登錄"
              :go-to "轉到"
              :or "或"
              :download "下載"
@@ -1139,6 +1151,8 @@ title: How to take dummy notes?
         :help/move-block-down "Skuif Blok Ondertoe"
         :help/create-new-block "Skep 'n nuwe blok"
         :help/new-line-in-block "Nuwe lyn in blok"
+        :help/open-top-right-open-button "Please click the top right 'Open' button to open local directory."
+        :help/select-nfs-browser "Please use another browser (like latest chrome) which support NFS feature to open local directory."
         :undo "Ontdoen"
         :redo "Herdoen"
         :help/zoom-in "Zoem in"
@@ -1306,6 +1320,7 @@ title: How to take dummy notes?
         :parsing-files "Lêer ontleding"
         :loading-files "Laai lêers"
         :login-github "Aantekening deur Github"
+        :login-google "Aantekening deur Google"
         :go-to "Gaan na "
         :or "of"
         :download "Laai af"