change code for review

This commit is contained in:
shixi_weimeng 2016-06-06 23:07:17 +08:00
parent 411ead21fc
commit 8459fcf7dc
2 changed files with 10 additions and 10 deletions

View File

@ -147,6 +147,14 @@ func (ua *UserAPI) Put() {
ua.CustomAbort(http.StatusForbidden, "Guests can only change their own account.")
}
}
user := models.User{UserID: ua.userID}
ua.DecodeJSONReq(&user)
err = commonValidate(user)
if err != nil {
log.Warning("Bad request in change user profile: %v", err)
ua.RenderError(http.StatusBadRequest, "change user profile error:"+err.Error())
return
}
userQuery := models.User{UserID: ua.userID}
u, err := dao.GetUser(userQuery)
if err != nil {
@ -157,14 +165,6 @@ func (ua *UserAPI) Put() {
log.Errorf("User with Id: %d does not exist", ua.userID)
ua.CustomAbort(http.StatusNotFound, "")
}
user := models.User{UserID: ua.userID}
ua.DecodeJSONReq(&user)
err = commonValidate(user)
if err != nil {
log.Warning("Bad request in change user profile: %v", err)
ua.RenderError(http.StatusBadRequest, "change user profile error:"+err.Error())
return
}
if u.Email != user.Email {
emailExist, err := dao.UserExists(user, "email")
if err != nil {

View File

@ -17,6 +17,6 @@ package models
// TopRepo holds information about repository that accessed most
type TopRepo struct {
RepoName string `json:"reponame"`
AccessCount int64 `json:"accesscount"`
RepoName string `json:"name"`
AccessCount int64 `json:"count"`
}