fix(modules/matrix): Handle login / logout corrently

This commit is contained in:
Jadyn Emma Jaeger 2022-08-01 11:38:22 +02:00
parent e065948d58
commit ee56b991fa
No known key found for this signature in database
GPG key ID: 632410170049FDDA
2 changed files with 8 additions and 5 deletions

View file

@ -43,7 +43,7 @@ class AnsibleNioModule:
add_file_common_args=False,
supports_check_mode=True,
required_if=None,
user_logout=True):
user_logout=None):
if required_by is None:
required_by = {'password': 'user_id'}
@ -57,9 +57,6 @@ class AnsibleNioModule:
if custom_spec is None:
custom_spec = {}
# If a user/password login is provided, should we logout when exiting?
self.user_logout = user_logout
# Create the Ansible module
self.module = AnsibleModule(
argument_spec=AnsibleNioModule.__common_argument_spec(custom_spec),
@ -74,6 +71,12 @@ class AnsibleNioModule:
required_by=required_by
)
if user_logout is None:
# If a user/password login is provided, should we logout when exiting?
self.user_logout = self.module.params['token'] is not None
else:
self.user_logout = user_logout
# Make some values from the module easly accessible
self.check_mode = self.module.check_mode
self.params = self.module.params

View file

@ -66,7 +66,7 @@ async def run_module():
changed=False,
)
module = AnsibleNioModule()
module = AnsibleNioModule(user_logout=True)
await module.matrix_login()
await module.matrix_logout()
await module.exit_json(**result)