mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-17 04:11:24 +01:00
change code for review
This commit is contained in:
parent
411ead21fc
commit
8459fcf7dc
16
api/user.go
16
api/user.go
@ -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 {
|
||||
|
@ -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"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user