Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: reload page when sign out (#871)
boojackb6f7a85a2abf
diff --git a/server/auth.go b/server/auth.goindex 3224e5f8f..f81245123 100644--- a/server/auth.go+++ b/server/auth.go@@ -54,20 +54,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {return nil})- g.POST("/auth/logout", func(c echo.Context) error {- ctx := c.Request().Context()- err := removeUserSession(c)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to set logout session").SetInternal(err)- }- s.Collector.Collect(ctx, &metric.Metric{- Name: "user logout",- })-- c.Response().WriteHeader(http.StatusOK)- return nil- })-g.POST("/auth/signup", func(c echo.Context) error {ctx := c.Request().Context()signup := &api.Signup{}@@ -143,4 +129,17 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {}return nil})++ g.POST("/auth/logout", func(c echo.Context) error {+ ctx := c.Request().Context()+ err := removeUserSession(c)+ if err != nil {+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to set logout session").SetInternal(err)+ }+ s.Collector.Collect(ctx, &metric.Metric{+ Name: "user logout",+ })++ return c.JSON(http.StatusOK, true)+ })}diff --git a/web/src/components/UserBanner.tsx b/web/src/components/UserBanner.tsxindex cd4176aa5..e640ff454 100644--- a/web/src/components/UserBanner.tsx+++ b/web/src/components/UserBanner.tsx@@ -1,6 +1,5 @@import { useCallback, useEffect, useState } from "react";import { useTranslation } from "react-i18next";-import { useNavigate } from "react-router-dom";import { useLocationStore, useMemoStore, useTagStore, useUserStore } from "../store/module";import { getMemoStats } from "../helpers/api";import * as utils from "../helpers/utils";@@ -13,7 +12,6 @@ import "../less/user-banner.less";const UserBanner = () => {const { t } = useTranslation();- const navigate = useNavigate();const locationStore = useLocationStore();const userStore = useUserStore();const memoStore = useMemoStore();@@ -66,7 +64,8 @@ const UserBanner = () => {};const handleSignOutBtnClick = async () => {- navigate("/auth");+ await userStore.doSignOut();+ window.location.href = "/auth";};return (diff --git a/web/src/store/module/user.ts b/web/src/store/module/user.tsindex ba537c0c3..6c3289c77 100644--- a/web/src/store/module/user.ts+++ b/web/src/store/module/user.ts@@ -92,7 +92,6 @@ const doSignIn = async () => {};const doSignOut = async () => {- store.dispatch(setUser());await api.signout();};