From 1f960f8f64acd5854ac5fb13863be9fcbf6af819 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Sun, 12 Dec 2021 01:26:46 +0800 Subject: [PATCH] Add: Handle logout --- pkg/api/api.go | 1 + web/src/component/Manage.js | 16 +++++++++++++++- web/src/component/Register.js | 3 +-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index b81e80e..abe1c62 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -81,6 +81,7 @@ func NewAPI(config Config) (*API, error) { // user apiMux.HandleFunc("/login", api.HandleLogin) apiMux.HandleFunc("/register", api.HandleRegister) + apiMux.HandleFunc("/logout", api.LoginAsAnonymous) // below needs token apiMux.HandleFunc("/walk", api.HandleWalk) apiMux.HandleFunc("/reset", api.HandleReset) diff --git a/web/src/component/Manage.js b/web/src/component/Manage.js index 3ac0410..f2304ae 100644 --- a/web/src/component/Manage.js +++ b/web/src/component/Manage.js @@ -39,7 +39,21 @@ function Manage(props) { )} {props.user.role !== 0 && ( - + )}