feat: delete account

pull/1312/head
Tienson Qin 2021-02-15 18:35:48 +08:00
parent c13cf6a75e
commit 7c586ec366
3 changed files with 65 additions and 15 deletions

View File

@ -111,6 +111,25 @@
(util/stop e))}
svg/external-link " release channel"]])])]))
(rum/defc delete-account-confirm
[close-fn]
(rum/with-context [[t] i18n/*tongue-context*]
[:div
(ui/admonition
:important
[:p.text-gray-700 (t :user/delete-account-notice)])
[:div.mt-5.sm:mt-4.sm:flex.sm:flex-row-reverse
[:span.flex.w-full.rounded-md.shadow-sm.sm:ml-3.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-transparent.px-4.py-2.bg-indigo-600.text-base.leading-6.font-medium.text-white.shadow-sm.hover:bg-indigo-500.focus:outline-none.focus:border-indigo-700.focus:shadow-outline-indigo.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click user-handler/delete-account!}
(t :user/delete-account)]]
[:span.mt-3.flex.w-full.rounded-md.shadow-sm.sm:mt-0.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-gray-300.px-4.py-2.bg-white.text-base.leading-6.font-medium.text-gray-700.shadow-sm.hover:text-gray-500.focus:outline-none.focus:border-blue-300.focus:shadow-outline-blue.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click close-fn}
"Cancel"]]]]))
(rum/defcs settings < rum/reactive
[]
(let [preferred-format (state/get-preferred-format)
@ -329,4 +348,16 @@
:on-click #(state/set-developer-mode! (not developer-mode?)))]]]
[:br]
(t :settings-page/developer-mode-desc)]]])))
(t :settings-page/developer-mode-desc)
[:hr]
(when logged?
[:div.sm:grid.sm:grid-cols-3.sm:gap-4.sm:items-start.sm:pt-5
[:label.block.text-sm.font-medium.leading-5.sm:mt-px.sm:pt-2.opacity-70.text-red-600
{:for "delete account"}
(t :user/delete-account)]
[:div.mt-1.sm:mt-0.sm:col-span-2
[:div.max-w-lg.rounded-md.shadow-sm.sm:max-w-xs
(ui/button (t :user/delete-your-account)
:on-click #(state/set-modal! delete-account-confirm))]]])]]])))

View File

@ -341,7 +341,10 @@ title: How to take dummy notes?
:dark "Dark"
:remove-background "Remove background"
:open "Open"
:open-a-directory "Open a local directory"}
:open-a-directory "Open a local directory"
:user/delete-account "Delete account"
:user/delete-your-account "Delete your account"
:user/delete-account-notice "All your published pages on logseq.com will be deleted."}
:de {:help/about "Über Logseq"
:help/bug "Fehlerbericht"
@ -1055,7 +1058,10 @@ title: How to take dummy notes?
:dark "暗黑"
:remove-background "去除背景"
:open "打开"
:open-a-directory "打开本地文件夹"}
:open-a-directory "打开本地文件夹"
:user/delete-account "删除帐号"
:user/delete-your-account "删除你的帐号"
:user/delete-account-notice "你在 logseq.com 发布的页面(假如有的话)也会被删除。"}
:zh-Hant {:on-boarding/title "你好,歡迎使用 Logseq"
:on-boarding/sharing "分享"

View File

@ -8,7 +8,8 @@
[promesa.core :as p]
[goog.object :as gobj]
[frontend.handler.notification :as notification]
[frontend.handler.config :as config-handler])
[frontend.handler.config :as config-handler]
[lambdaisland.glogi :as log])
(:import [goog.format EmailAddress]))
(defn email? [v]
@ -63,12 +64,24 @@
(fn [_e])))))
(defn sign-out!
[_e]
(when (js/confirm "Your local notes will be completely removed after signing out. Continue?")
([]
(sign-out! true))
([confirm?]
(when (or (not confirm?)
(js/confirm "Your local notes will be completely removed after signing out. Continue?"))
(->
(idb/clear-local-storage-and-idb!)
(p/catch (fn [e]
(println "sign out error: ")
(js/console.dir e)))
(p/finally (fn []
(set! (.-href js/window.location) "/logout"))))))
(set! (.-href js/window.location) "/logout")))))))
(defn delete-account!
[]
(p/let [_ (idb/clear-local-storage-and-idb!)]
(util/delete (str config/api "account")
(fn []
(sign-out! false))
(fn [error]
(log/error :user/delete-account-failed error)))))