From ee65be7bac21c1e86724faef83a47da92433da26 Mon Sep 17 00:00:00 2001 From: Adhityaa Date: Tue, 5 Jun 2018 14:23:32 +0530 Subject: [PATCH] frontend: add logout --- api/router_static.go | 1 + frontend/Makefile | 3 ++- frontend/js/logout.js | 8 ++++++++ frontend/logout.html | 10 ++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 frontend/js/logout.js create mode 100644 frontend/logout.html diff --git a/api/router_static.go b/api/router_static.go index 868cb4f..19dc7ae 100644 --- a/api/router_static.go +++ b/api/router_static.go @@ -63,6 +63,7 @@ func initStaticRouter(router *mux.Router) error { "login", "signup", "dashboard", + "logout", "account", } diff --git a/frontend/Makefile b/frontend/Makefile index 8654128..5dfb413 100644 --- a/frontend/Makefile +++ b/frontend/Makefile @@ -1,7 +1,7 @@ SHELL = bash # list of JS files to be built -JS_BUILD = jquery.js vue.js highlight.js chartist.js login.js signup.js dashboard.js +JS_BUILD = jquery.js vue.js highlight.js chartist.js login.js signup.js dashboard.js logout.js jquery.js = jquery.js vue.js = vue.js @@ -10,6 +10,7 @@ chartist.js = chartist.js login.js = utils.js http.js auth-common.js login.js signup.js = utils.js http.js auth-common.js signup.js dashboard.js = utils.js http.js errors.js self.js dashboard.js dashboard-setting.js dashboard-domain.js dashboard-installation.js dashboard-general.js dashboard-moderation.js dashboard-statistics.js dashboard-import.js dashboard-danger.js +logout.js = utils.js logout.js # for each file in $(JS_BUILD), list its composition diff --git a/frontend/js/logout.js b/frontend/js/logout.js new file mode 100644 index 0000000..b9da814 --- /dev/null +++ b/frontend/js/logout.js @@ -0,0 +1,8 @@ +(function (global, document) { + + global.logout = function() { + global.cookieSet("session", ""); + document.location = "/login"; + } + +} (window, document)); diff --git a/frontend/logout.html b/frontend/logout.html new file mode 100644 index 0000000..52b17f8 --- /dev/null +++ b/frontend/logout.html @@ -0,0 +1,10 @@ + + + + + + + +