fix: resource api

This commit is contained in:
email
2022-02-04 18:54:24 +08:00
parent d609f2741d
commit 4535e0ce6d
8 changed files with 47 additions and 19 deletions

View File

@ -11,7 +11,13 @@ import (
func (s *Server) registerUserRoutes(g *echo.Group) {
g.GET("/user/me", func(c echo.Context) error {
userId := c.Get(getUserIdContextKey()).(int)
// /api/user/me is used to check if the user is logged in,
userSessionId := c.Get(getUserIdContextKey())
if userSessionId == nil {
return echo.NewHTTPError(http.StatusUnauthorized, "Missing session")
}
userId := userSessionId.(int)
userFind := &api.UserFind{
Id: &userId,
}