1
0

Enable searching users by full email or name

This commit is contained in:
kolaente
2021-04-07 18:28:58 +02:00
parent 8ddc00bd29
commit 126f3acdc8
14 changed files with 191 additions and 42 deletions

View File

@ -19,6 +19,8 @@ package v1
import (
"net/http"
"code.vikunja.io/api/pkg/user"
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/api/pkg/modules/auth"
@ -28,6 +30,11 @@ import (
"github.com/labstack/echo/v4"
)
type userWithSettings struct {
user.User
Settings *UserSettings `json:"settings"`
}
// UserShow gets all informations about the current user
// @Summary Get user information
// @Description Returns the current user object.
@ -48,10 +55,20 @@ func UserShow(c echo.Context) error {
s := db.NewSession()
defer s.Close()
user, err := models.GetUserOrLinkShareUser(s, a)
u, err := models.GetUserOrLinkShareUser(s, a)
if err != nil {
return handler.HandleHTTPError(err, c)
}
return c.JSON(http.StatusOK, user)
us := &userWithSettings{
User: *u,
Settings: &UserSettings{
Name: u.Name,
EmailRemindersEnabled: u.EmailRemindersEnabled,
DiscoverableByName: u.DiscoverableByName,
DiscoverableByEmail: u.DiscoverableByEmail,
},
}
return c.JSON(http.StatusOK, us)
}