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

user.enable doesn't work after a user was disabled in the project #1519

Open
sirkozuch opened this issue Apr 10, 2019 · 1 comment
Open

user.enable doesn't work after a user was disabled in the project #1519

sirkozuch opened this issue Apr 10, 2019 · 1 comment

Comments

@sirkozuch
Copy link

sirkozuch commented Apr 10, 2019

I'm currently trying to use Ruby SDK to create an application for user management. Came across the cookbook, specifically the manual how to enable and disable users in the project.

After deactivating a user, I can see the user in the deactivated section of the users in the project. Afterwards, I'd like to re-enable the user, but I receive the following message:

undefined method `enable' for nil:NilClass (NoMethodError)
        from /Library/Ruby/Gems/2.3.0/gems/gooddata-2.1.3/lib/gooddata/core/project.rb:63:in `with_project'
        from test.rb:14:in `block in <main>'
        from /Library/Ruby/Gems/2.3.0/gems/gooddata-2.1.3/lib/gooddata/connection.rb:47:in `with_connection'
        from test.rb:13:in `<main>'

I guess, the issue is, that when I type in project.member?('[email protected]') I receive false, as if the user was not in the project, although I see him in the deactivated section.

I really need to deactivate the user and then re-activate him, but it does not seem possible at the moment.

Is this an expected behavior? Are there any workaround?

Code:

# deactivate

GoodData.with_connection('[email protected]', 'abcd1234') do |client|
  GoodData.with_project('xxxxxxx') do |project|

    pp project.member?('[email protected]') # returns True
    user = project.member([email protected]')
    user.disable
  end
end
# activate back

GoodData.with_connection('[email protected]', 'abcd1234') do |client|
  GoodData.with_project('xxxxxxx') do |project|

    pp project.member?('[email protected]') # returns False
    user = project.member([email protected]') # doesn't initiate
    user.enable
  end
end
@panjan
Copy link
Contributor

panjan commented Apr 15, 2019

Hello @SMKozuch, thanks for filing the issue. The #member method only works with enabled users. Here's a possible workaround:

disabled_users = project.users(disabled: true) # or project.users(all: true)
project.member('[email protected]', disabled_users)

I will document the disabled and all options when I have the time. We could also make #member accept these options (e.g. project.member([email protected]', all: true)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants