Project

General

Profile

Bug #4537

Unsetting roles via API does not work

Added by Marek Hulán over 5 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

When user tries to set empty array of role_ids, he receives

{
    "error": {
        "message": "undefined method `uniq' for nil:NilClass" 
    }
}
Started PUT "/foreman/api/users/13" for 127.0.0.1 at 2014-03-04 09:40:34 +0100
Processing by Api::V1::UsersController#update as JSON
  Parameters: {"user"=>{"login"=>"somelogin", "role_ids"=>nil}, "apiv"=>"v1", "id"=>"13"}
  User Load (0.4ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
Setting current user thread-local variable to admin
  User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."login" = '13' ORDER BY firstname LIMIT 1
  User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 13 ORDER BY firstname LIMIT 1
   (0.2ms)  BEGIN
   (0.1ms)  ROLLBACK
undefined method `uniq' for nil:NilClass (NoMethodError)
/home/ares/Projekty/Zdrojaky/foreman/app/models/user.rb:272:in `role_ids_with_change_detection='

Associated revisions

Revision 615ff085 (diff)
Added by Marek Hulán over 5 years ago

Fixes #4537 - user can set empty roles array via API

History

#1 Updated by Marek Hulán over 5 years ago

  • Status changed from Assigned to Ready For Testing
  • Legacy Backlogs Release (now unused) set to 4

#3 Updated by Marek Hulán over 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF