Update external users other than Internal like Ldap, Ouath2, Kerberos, Webserver.
(username: str,
auth_source: AuthExtTypes = AuthExtTypes.oauth2,
email: Optional[str] = None,
admin: Annotated[Optional[bool], typer.Option(
"--admin")] = False,
role: Optional[str] = None,
active: Annotated[
Optional[bool],
typer.Option("--active/--inactive")] = None,
console: Optional[bool] = True,
json: Optional[bool] = False,
sqlite_path: Optional[str] = None,
)
| 497 | @app.command() |
| 498 | @update_sqlite_path |
| 499 | def update_external_user(username: str, |
| 500 | auth_source: AuthExtTypes = AuthExtTypes.oauth2, |
| 501 | email: Optional[str] = None, |
| 502 | admin: Annotated[Optional[bool], typer.Option( |
| 503 | "--admin")] = False, |
| 504 | role: Optional[str] = None, |
| 505 | active: Annotated[ |
| 506 | Optional[bool], |
| 507 | typer.Option("--active/--inactive")] = None, |
| 508 | console: Optional[bool] = True, |
| 509 | json: Optional[bool] = False, |
| 510 | sqlite_path: Optional[str] = None, |
| 511 | ): |
| 512 | """Update external users other than Internal like |
| 513 | Ldap, Ouath2, Kerberos, Webserver.""" |
| 514 | |
| 515 | data = dict() |
| 516 | if email: |
| 517 | data['email'] = email |
| 518 | if role is not None: |
| 519 | data['role'] = role |
| 520 | if admin: |
| 521 | data['role'] = 'Administrator' |
| 522 | if active is not None: |
| 523 | data['active'] = active |
| 524 | |
| 525 | app = create_app(config.APP_NAME + '-cli') |
| 526 | with app.test_request_context(): |
| 527 | rid = ManageRoles.get_role(data['role']) |
| 528 | if rid is None: |
| 529 | print("Role '{0}' does not exists.".format(data['role'])) |
| 530 | exit() |
| 531 | |
| 532 | data['role'] = rid |
| 533 | |
| 534 | uid = ManageUsers.get_user(username=username, |
| 535 | auth_source=auth_source) |
| 536 | if not uid: |
| 537 | print(USER_NOT_FOUND_STR) |
| 538 | else: |
| 539 | status, msg = user_management_update_user(uid, data) |
| 540 | if status: |
| 541 | _user = ManageUsers.get_users_from_db( |
| 542 | username=username, |
| 543 | auth_source=auth_source, |
| 544 | console=False |
| 545 | ) |
| 546 | ManageUsers.display_user(_user[0], console, json) |
| 547 | else: |
| 548 | print(SOMETHING_WENT_WRONG + str(msg)) |
| 549 | |
| 550 | def create_user(data, console, json): |
| 551 | app = create_app(config.APP_NAME + '-cli') |
nothing calls this directly
no test coverage detected