From 24b21aa9d75d8792d195cc127583c096f3114765 Mon Sep 17 00:00:00 2001 From: boojack Date: Sat, 31 Dec 2022 15:40:53 +0800 Subject: [PATCH] chore: update version to `0.9.1` (#882) --- server/memo.go | 25 ++++++++++++------- server/server.go | 2 ++ server/version/version.go | 4 ++-- web/src/components/AboutSiteDialog.tsx | 33 +++++++++++++------------- web/src/components/Sidebar.tsx | 6 ++--- 5 files changed, 40 insertions(+), 30 deletions(-) diff --git a/server/memo.go b/server/memo.go index d22f398a..e00b27a3 100644 --- a/server/memo.go +++ b/server/memo.go @@ -315,19 +315,14 @@ func (s *Server) registerMemoRoutes(g *echo.Group) { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err) } - currentTs := time.Now().Unix() - memoResourceUpsert := &api.MemoResourceUpsert{ - UpdatedTs: ¤tTs, + userID, ok := c.Get(getUserIDContextKey()).(int) + if !ok { + return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session") } + memoResourceUpsert := &api.MemoResourceUpsert{} if err := json.NewDecoder(c.Request().Body).Decode(memoResourceUpsert); err != nil { return echo.NewHTTPError(http.StatusBadRequest, "Malformatted post memo resource request").SetInternal(err) } - memoResourceUpsert.MemoID = memoID - - if _, err := s.Store.UpsertMemoResource(ctx, memoResourceUpsert); err != nil { - return echo.NewHTTPError(http.StatusInternalServerError, "Failed to upsert memo resource").SetInternal(err) - } - resourceFind := &api.ResourceFind{ ID: &memoResourceUpsert.ResourceID, } @@ -335,6 +330,18 @@ func (s *Server) registerMemoRoutes(g *echo.Group) { if err != nil { return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch resource").SetInternal(err) } + if resource == nil { + return echo.NewHTTPError(http.StatusBadRequest, "Resource not found").SetInternal(err) + } else if resource.CreatorID != userID { + return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized to bind this resource").SetInternal(err) + } + + memoResourceUpsert.MemoID = memoID + currentTs := time.Now().Unix() + memoResourceUpsert.UpdatedTs = ¤tTs + if _, err := s.Store.UpsertMemoResource(ctx, memoResourceUpsert); err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, "Failed to upsert memo resource").SetInternal(err) + } c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8) if err := json.NewEncoder(c.Response().Writer).Encode(composeResponse(resource)); err != nil { diff --git a/server/server.go b/server/server.go index 5e57ea8a..b66e5198 100644 --- a/server/server.go +++ b/server/server.go @@ -42,6 +42,8 @@ func NewServer(profile *profile.Profile) *Server { e.Use(middleware.CORS()) + e.Use(middleware.Secure()) + e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{ Skipper: middleware.DefaultSkipper, ErrorMessage: "Request timeout", diff --git a/server/version/version.go b/server/version/version.go index ee5a0da2..6f83fda9 100644 --- a/server/version/version.go +++ b/server/version/version.go @@ -7,10 +7,10 @@ import ( // Version is the service current released version. // Semantic versioning: https://semver.org/ -var Version = "0.9.0" +var Version = "0.9.1" // DevVersion is the service current development version. -var DevVersion = "0.9.0" +var DevVersion = "0.9.1" func GetCurrentVersion(mode string) string { if mode == "dev" { diff --git a/web/src/components/AboutSiteDialog.tsx b/web/src/components/AboutSiteDialog.tsx index 1636351f..3c171edf 100644 --- a/web/src/components/AboutSiteDialog.tsx +++ b/web/src/components/AboutSiteDialog.tsx @@ -11,6 +11,7 @@ const AboutSiteDialog: React.FC = ({ destroy }: Props) => { const { t } = useTranslation(); const globalStore = useGlobalStore(); const profile = globalStore.state.systemStatus.profile; + const customizedProfile = globalStore.state.systemStatus.customizedProfile; const handleCloseBtnClick = () => { destroy(); @@ -20,36 +21,36 @@ const AboutSiteDialog: React.FC = ({ destroy }: Props) => { <>

- - {t("common.about")} memos + {t("common.about")} {customizedProfile.name}

-

{t("slogan")}

-
- Other projects: +

{customizedProfile.description || "No description"}

+
+
+ Powered by + + + memos + + v{profile.version} +
+ +
+
+ Other projects: Sticky notes
-
- - - {t("common.version")}: - - {profile.version}-{profile.mode} - - 🎉 - -
); diff --git a/web/src/components/Sidebar.tsx b/web/src/components/Sidebar.tsx index 8ffdf58f..30fb2f94 100644 --- a/web/src/components/Sidebar.tsx +++ b/web/src/components/Sidebar.tsx @@ -35,11 +35,11 @@ const Sidebar = () => { + + 🏂 {t("common.explore")} + {!userStore.isVisitorMode() && ( <> - - 🏂 {t("common.explore")} -