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

fix(jans-cli-tui): user management fixes #8136

Merged
merged 4 commits into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions jans-cli-tui/cli_tui/plugins/070_users/edit_user_dialog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Optional, Sequence, Callable
import asyncio
from functools import partial

from prompt_toolkit import HTML
from prompt_toolkit.layout.dimension import D
from prompt_toolkit.layout.containers import HSplit, VSplit,\
DynamicContainer, Window
Expand Down Expand Up @@ -235,7 +237,8 @@ def add_claim(self) -> None:
continue
if claim['name'] in ('memberOf', 'userPassword', 'uid', 'jansStatus', 'jansActive', 'updatedAt'):
continue
claims_list.append((claim['name'], claim['displayName']))
if claim.get('status') == 'active':
claims_list.append((claim['name'], claim['displayName']))

claims_checkbox = CheckboxList(values=claims_list)

Expand All @@ -253,7 +256,7 @@ def add_claim(dialog) -> None:
self.edit_user_container = ScrollablePane(content=HSplit(self.edit_user_content, width=D()),show_scrollbar=False)


body = HSplit([Label(_("Select claim to be added to current user.")), claims_checkbox])
body = HSplit([Label(HTML(_("Select claim to be added to current user.\n<i>Note</i>: Only <b>active</b> claims are displayed."))), claims_checkbox])
buttons = [Button(_("Cancel")), Button(_("OK"), handler=add_claim)]
dialog = JansGDialog(common_data.app, title=_("Claims"), body=body, buttons=buttons, width=common_data.app.dialog_width-20)
common_data.app.show_jans_dialog(dialog)
Expand All @@ -278,7 +281,7 @@ def save_user(self) -> None:
common_data.app.show_message(fix_title, _("Please enter Password"))
return

user_info = {'customObjectClasses':['top', 'jansPerson'], 'customAttributes':[]}
user_info = {'customObjectClasses':['top', 'jansPerson', 'jansCustomPerson'], 'customAttributes':[]}
for key_ in ('mail', 'userId', 'displayName', 'givenName'):
user_info[key_] = raw_data.pop(key_)

Expand Down Expand Up @@ -335,7 +338,7 @@ async def coroutine():
common_data.app.start_progressing(_("Saving user ..."))
response = await common_data.app.loop.run_in_executor(common_data.app.executor, common_data.app.cli_requests, cli_args)
common_data.app.stop_progressing()
if response.status_code != 201:
if response.status_code not in (200, 201):
common_data.app.show_message(_('Error'), response.text + '\n' + response.reason)
else:
self.future.set_result(DialogResult.OK)
Expand Down