Skip to content

Commit

Permalink
feat: Prevent guest user changing password
Browse files Browse the repository at this point in the history
  • Loading branch information
jwma committed Feb 17, 2022
1 parent bf48079 commit 35ea37f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/app/handlers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func LogoutAPI() gin.HandlerFunc {
// @Router /user/change-password [post]
func ChangePasswordAPI() gin.HandlerFunc {
return Authenticator(func(c *gin.Context, user *models.User) {
if user.Username == "guest" {
c.JSON(http.StatusOK, models.NewErrorResponse("该账号不支持修改密码"))
return
}

p := &models.ChangePasswordAPIRequest{}
if err := c.ShouldBindJSON(p); err != nil {
c.JSON(http.StatusOK, models.NewErrorResponse("请填写原密码和新密码"))
Expand Down

0 comments on commit 35ea37f

Please sign in to comment.