Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#6285](https://github.com/apache/trafficcontrol/issues/6285) - The Traffic Ops Postinstall script will work in CentOS 7, even if Python 3 is installed
- [#5373](https://github.com/apache/trafficcontrol/issues/5373) - Traffic Monitor logs not consistent
- Traffic Ops: Sanitize username before executing LDAP query
- [#6367](https://github.com/apache/trafficcontrol/issues/6367) - Fix PUT `user/current` to work with v4 User Roles and Permissions

### Changed
- Updated `t3c` to request less unnecessary deliveryservice-server assignment and invalidation jobs data via new query params supported by Traffic Ops
Expand Down
2 changes: 1 addition & 1 deletion lib/go-tc/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ type UserResponseV4 struct {
// "undefined" values.
type CurrentUserUpdateRequest struct {
// User, for whatever reason, contains all of the actual data.
User CurrentUserUpdateRequestUser `json:"user"`
User *CurrentUserUpdateRequestUser `json:"user"`
}

// CurrentUserUpdateRequestUser holds all of the actual data in a request to update the current user.
Expand Down
14 changes: 9 additions & 5 deletions traffic_ops/traffic_ops_golang/user/current.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ WHERE u.id=$1

func ReplaceCurrent(w http.ResponseWriter, r *http.Request) {
var useV4User bool
var userV4 tc.UserV4
inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
tx := inf.Tx.Tx
if userErr != nil || sysErr != nil {
Expand All @@ -183,13 +182,18 @@ func ReplaceCurrent(w http.ResponseWriter, r *http.Request) {
api.HandleErr(w, r, tx, errCode, userErr, nil)
return
}

if userRequest.User == nil {
errCode = http.StatusBadRequest
userErr = fmt.Errorf("missing required 'user' object")
api.HandleErr(w, r, tx, errCode, userErr, nil)
return
}

if inf.Version.Major >= 4 {
useV4User = true
}
user, exists, err := dbhelpers.GetUserByID(inf.User.ID, tx)
if useV4User {
userV4 = user.Upgrade()
}
if err != nil {
sysErr = fmt.Errorf("getting user by ID %d: %v", inf.User.ID, err)
errCode = http.StatusInternalServerError
Expand Down Expand Up @@ -317,7 +321,7 @@ func ReplaceCurrent(w http.ResponseWriter, r *http.Request) {
}

if useV4User {
api.WriteRespAlertObj(w, r, tc.SuccessLevel, "User profile was successfully updated", userV4)
api.WriteRespAlertObj(w, r, tc.SuccessLevel, "User profile was successfully updated", user.Upgrade())
} else {
api.WriteRespAlertObj(w, r, tc.SuccessLevel, "User profile was successfully updated", user)
}
Expand Down