From 4470b7ba9c5957de174471bd7c946fb64020ce5d Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sun, 12 Aug 2018 09:31:50 +0800 Subject: [PATCH] Add missing logout --- resources/assets/src/js/index.js | 1 + resources/assets/src/js/logout.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 resources/assets/src/js/logout.js diff --git a/resources/assets/src/js/index.js b/resources/assets/src/js/index.js index bb8c2a83..3a1ab3b6 100644 --- a/resources/assets/src/js/index.js +++ b/resources/assets/src/js/index.js @@ -1,3 +1,4 @@ import './i18n'; import './net'; import './layout'; +import './logout'; diff --git a/resources/assets/src/js/logout.js b/resources/assets/src/js/logout.js new file mode 100644 index 00000000..a40de192 --- /dev/null +++ b/resources/assets/src/js/logout.js @@ -0,0 +1,25 @@ +import { post } from './net'; +import { swal } from './notify'; +import { trans } from './i18n'; + +export async function logout() { + const { dismiss } = await swal({ + text: trans('general.confirmLogout'), + type: 'warning', + showCancelButton: true, + confirmButtonText: trans('general.confirm'), + cancelButtonText: trans('general.cancel') + }); + if (dismiss) { + return; + } + + const { msg } = await post('/auth/logout'); + setTimeout(() => window.location = blessing.base_url, 1000); + swal({ + type: 'success', + html: msg + }); +} + +$('#logout-button').click(logout);