Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #5750 - Add Org Ids to Users BZ1092656 #1450

Closed

Conversation

dustints
Copy link

Unable to create a user from the api with a default-organization-id set.
validation is present to check that a user's default-organization must
be a member user's organizations. the only way to pass validation is to
allow passing both organization and default organization during
creation.

@domcleal
Copy link
Contributor

@isratrade could you review this?

My concern is that this only adds one taxonomy to one controller, it should be universal if anything. I'm pretty sure we've discussed this before, but I can't remember the outcome.

Just a couple of notes about style - please only use redmine issue numbers (no RHBZ), and keep commit messages to a single line.

@domcleal
Copy link
Contributor

Sorry, one more thing: how does this fix the undefined method error in the linked bug report? (http://projects.theforeman.org/issues/5750) This should only be a change in documentation.

@dustints
Copy link
Author

Hi @domcleal ,
Could users be a special case. I think some of the taxonomy resources in the api don't allow organizations to be set on creation. Also unique to User is that it can have a default_organization, but because of validation, we're unable to assign default_organization without the user having an association with that organization.

Sorry about poorly formatted commit message. I will update.

The undefined method error doesn't seem to be the issue any longer, but I wanted to still address the user's need to be able to define a default organization at user creation.

@isratrade
Copy link
Member

@dustint-rh, you can add organizations by using a node in the JSON payload that you POST. For example:

{
    "login": "test124",
    "firstname": "bob",
    "lastname": "smith",
    "mail": "test124@redhat.com",
    "admin": false,
    "auth_source_id": 10,
    "default_organization_id": 1,
    "organizations": [
        {
            "id": 1,
            "name": "Foreman"
        }
    ]
}

I need to check if this is documented in the Foreman Manuel.

@dustints
Copy link
Author

Hi @isratrade, sorry didn't mention that this change would be helpful for the services that use apipie-bindings. I think hammer cli wouldn't be able to pass organization-ids without this change.

@isratrade
Copy link
Member

@dustint-rh, I think you can still pass a parameter called organization_ids even if it's not documentated as Ruby on Rails allows this out of the box for all has_many assocations. We did not white-list of possible params using attr_accessible in user.rb so it should be fine.

@domcleal
Copy link
Contributor

Agreed, it's just that apipie-bindings runs off the apipie documentation, so really we need full apipie documentation of ids/names parameters/has_many relationships, which is missing today. I'd rather solve it generally than fix just one instance of many.

@dustints
Copy link
Author

@domcleal @isratrade thanks! will close this PR and open an issue in redmine

@dustints dustints closed this May 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reached an impasse Needs broader discussion
Projects
None yet
3 participants