Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUT /users確認 #835

Open
H1rono opened this issue Dec 29, 2024 · 1 comment
Open

PUT /users確認 #835

H1rono opened this issue Dec 29, 2024 · 1 comment

Comments

@H1rono
Copy link
Member

H1rono commented Dec 29, 2024

Jomon/router/user.go

Lines 54 to 81 in 27d5da6

func (h Handlers) UpdateUserInfo(c echo.Context) error {
var newUser PutUserRequest
if err := c.Bind(&newUser); err != nil {
h.Logger.Info("could not get user info from request", zap.Error(err))
return c.NoContent(http.StatusBadRequest)
}
user, err := h.Repository.GetUserByName(c.Request().Context(), newUser.Name)
if err != nil {
h.Logger.Error("failed to get user from repository", zap.Error(err))
return echo.NewHTTPError(http.StatusBadRequest, err)
}
updated, err := h.Repository.UpdateUser(
c.Request().Context(),
user.ID, newUser.Name, newUser.DisplayName, newUser.Admin)
if err != nil {
h.Logger.Error("failed to update user in repository", zap.Error(err))
return echo.NewHTTPError(http.StatusInternalServerError, err)
}
return c.JSON(http.StatusOK, User{
ID: user.ID,
Name: updated.Name,
DisplayName: updated.DisplayName,
Admin: updated.Admin,
})
}

  • ID取得周りのロジックに違和感がある
  • Nameを変更できない
  • 自分以外の情報を変更できそう

あたり

@H1rono
Copy link
Member Author

H1rono commented Dec 29, 2024

CreatedAt, UpdatedAt, DeletedAtがレスポンスのフィールドで指定されていない(これコンパイルエラーにできないの、終わってる)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant