Jump to content

User 'is_active' - True + True = False ?


Remus Avram

Recommended Posts

Hi Ftrack,

we are using the API for enabling/disabling the users in Ftrack.

We have a short method for this:
    if user:
        try:
            user['is_active'] = True
            ftrack_session_manager.main_session.commit()
        except Exception, e:
            ftrack_session_manager.main_session.rollback()
            log.error("User '%s' couldn't be enabled! Error: '%s'" % (user['username'], e))

There is a small error when we try to enable a user which is already enabled. If user['is_active'] == True, and we try to enabling it again it gets disabled.

Is it the normal behaviour?

Sure we can check if the user is enable before enabling it again, but I think the check should be done at the API level.

Cheers, Rermus

Link to comment
Share on other sites

Hi Remus,

This was very odd!

I've been able to reproduce this behaviour if I maxing out my licenses while doing this. E.g. I have 100 user enabled and have 100 licenses. A bug in the validation in our backend then stops the enabling of what it believes is an additional user, and reverts it back to disabled. Is this your situation too?

Link to comment
Share on other sites

Hi Mattias! Thanks for your answer!

Currently versions:

Ftrack Server: 3.3.33

Ftrack API: 0.16.0

This issue we have even if we don't reach the limit of the licenses. It seems that you are using 'xor'.

True + True = False

True + False = True

False + True = True

False + False = False

Unfortunately, I did't have the time to check deeper in the API code.

Link to comment
Share on other sites

Strange. For us it behave different:

(Pdb) print user
<User(54d2a150-4839-11e6-a626-005056a745dd)>
(Pdb) print user['is_active']
True
(Pdb) user['is_active'] = True
(Pdb) print user['is_active']
True
(Pdb) ftrack_session_manager.main_session.commit()
requests.packages.urllib3.connectionpool> INFO | Resetting dropped connection: ftrack.server
(Pdb) print user['is_active']
False

The only difference is that we are using a global session.

 

Link to comment
Share on other sites

16 hours ago, Remus Avram said:

The only difference is that we are using a global session.

Odd, I cannot see how that would matter :-/ And you do not have any issues with the license on the server you're trying on?

I've done some testing and for me it seems like the correct data is sent to the server. If the license check "can I enable more users" fails for any reason (invalid license, on the limit of number of licenses etc.) it will be changed to "False" regardless of the original value..

Link to comment
Share on other sites

Hi Mattias! Sure. I am running the script with my user (person, no global api key). And I have the following roles: 'Administrator', 'API'. I am testing against a test user.

But if it's working for you, then I will just add check before activating the user again. There is not necessary spending too much time on this. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...