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
chore: update list user api permission
Stevene67820cabe0e
diff --git a/api/v1/user.go b/api/v1/user.goindex dbb69739c..67359f56e 100644--- a/api/v1/user.go+++ b/api/v1/user.go@@ -88,6 +88,23 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {// @Router /api/v1/user [GET]func (s *APIV1Service) GetUserList(c echo.Context) error {ctx := c.Request().Context()+ userID, ok := c.Get(userIDContextKey).(int32)+ if !ok {+ return echo.NewHTTPError(http.StatusUnauthorized, "Missing auth session")+ }+ currentUser, err := s.Store.GetUser(ctx, &store.FindUser{+ ID: &userID,+ })+ if err != nil {+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find user by id").SetInternal(err)+ }+ if currentUser == nil {+ return echo.NewHTTPError(http.StatusUnauthorized, "Missing auth session")+ }+ if currentUser.Role != store.RoleHost && currentUser.Role != store.RoleAdmin {+ return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized to list users")+ }+list, err := s.Store.ListUsers(ctx, &store.FindUser{})if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch user list").SetInternal(err)