Skip to content

Commit

Permalink
Merge branch 'main' into release/0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Nov 12, 2023
2 parents 12cf0f8 + af9655e commit 70f6f30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/v1/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func JWTMiddleware(s *APIV1Service, next echo.HandlerFunc, secret string) echo.H
accessToken := findAccessToken(c)
if accessToken == "" {
// When the request is not authenticated, we allow the user to access the shortcut endpoints for those public shortcuts.
if util.HasPrefixes(path, "/s/") && method == http.MethodGet {
if util.HasPrefixes(path, "/s/", "/api/v1/user/") && method == http.MethodGet {
return next(c)
}
return echo.NewHTTPError(http.StatusUnauthorized, "Missing access token")
Expand Down
7 changes: 6 additions & 1 deletion api/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to find user, err: %s", err)).SetInternal(err)
}

return c.JSON(http.StatusOK, convertUserFromStore(user))
userMessage := convertUserFromStore(user)
userID, ok := c.Get(userIDContextKey).(int32)
if !ok {
userMessage.Email = ""
}
return c.JSON(http.StatusOK, userMessage)
})

g.PATCH("/user/:id", func(c echo.Context) error {
Expand Down

0 comments on commit 70f6f30

Please sign in to comment.