Skip to content

Update user with different username creates new user #355

@fbalak

Description

@fbalak

When any user (admin or normal) tries to change its user data via API:

curl -H 'Content-Type: application/json' -H 'Authorization: Bearer token' -XPUT -d '{"name":"Tom Hardy", "username":"thardy2", "email":"thardy2@tendrl.org", "role":"normal"}' http://127.0.0.1/api/1.0/users/thardy

and provide different username and email (same email returns message: is taken) than the one that the user already have then there is created a new user with the new provided username and empty role ("role": null) and the old user stays unchanged:

curl -H 'Content-Type: application/json' -H 'Authorization: Bearer token' -XGET http://127.0.0.1/api/1.0/users

Status: 200 OK
[{
  "email": "admin@tendrl.org",
  "username": "admin",
  "name": "Admin",
  "role": "admin",
  "email_notitifications": true
}, {
  "email": "thardy@tendrl.org",
  "username": "thardy",
  "name": "Tom Hardy",
  "role": "admin",
  "email_notifications": false
}, {
  "email": "thardy2@tendrl.org",
  "username": "thardy2",
  "name": "Tom Hardy",
  "role": null,
  "email_notifications": false
}]

Tested with:

tendrl-ansible-1.5.4-1.el7.centos.noarch
tendrl-api-1.5.5-1.el7.centos.noarch
tendrl-api-httpd-1.5.5-1.el7.centos.noarch
tendrl-commons-1.5.5-1.el7.centos.noarch
tendrl-grafana-plugins-1.5.5-1.el7.centos.noarch
tendrl-grafana-selinux-1.5.4-2.el7.centos.noarch
tendrl-monitoring-integration-1.5.5-1.el7.centos.noarch
tendrl-node-agent-1.5.5-1.el7.centos.noarch
tendrl-notifier-1.5.5-1.el7.centos.noarch
tendrl-selinux-1.5.4-2.el7.centos.noarch
tendrl-ui-1.5.5-1.el7.centos.noarch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions