Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

better errors handler user id

Smaug67390a796420abdd
diff --git a/backend/controllers/users.controller.go b/backend/controllers/users.controller.go
index 38cd4ec0..33d06aba 100644
--- a/backend/controllers/users.controller.go
+++ b/backend/controllers/users.controller.go
@@ -199,7 +199,10 @@ func (ctr *UserControllerImpl) UpdateUser(c *gin.Context) (int, any) {
// @Failure 401 {object} Error
func (ctr *UserControllerImpl) UpdatePassword(c *gin.Context) (int, any) {
- id, _ := utils.GetUserIdParam(c.Param("id"), c)
+ id, err := utils.GetUserIdParam(c.Param("id"), c)
+ if err != nil {
+ return http.StatusBadRequest, err
+ }
userId, err := utils.GetUserIdCtx(c)
if err != nil {
diff --git a/backend/utils/permissions.go b/backend/utils/permissions.go
index eb0e5527..d2f9f739 100644
--- a/backend/utils/permissions.go
+++ b/backend/utils/permissions.go
@@ -27,7 +27,7 @@ func GetUserIdParam(param string, ctx *gin.Context) (int64, error) {
if param != "@me" {
id_param, err := strconv.ParseInt(ctx.Param("id"), 10, 64)
if err != nil {
- return 0, err
+ return 0, errors.New("invalid user ID parameter")
}
return id_param, nil
}