(data, console, json)
| 548 | print(SOMETHING_WENT_WRONG + str(msg)) |
| 549 | |
| 550 | def create_user(data, console, json): |
| 551 | app = create_app(config.APP_NAME + '-cli') |
| 552 | with app.test_request_context(): |
| 553 | username = data['username'] if 'username' in data else \ |
| 554 | data['email'] |
| 555 | |
| 556 | rid = ManageRoles.get_role(data['role']) |
| 557 | if rid is None: |
| 558 | print("Role '{0}' does not exists.".format(data['role'])) |
| 559 | exit() |
| 560 | |
| 561 | data['role'] = rid |
| 562 | |
| 563 | uid = ManageUsers.get_user(username=username, |
| 564 | auth_source=data['auth_source']) |
| 565 | if uid: |
| 566 | print("User already exists.") |
| 567 | exit() |
| 568 | |
| 569 | if 'newPassword' in data and len(data['newPassword']) < 6: |
| 570 | print("Password must be at least 6 characters long.") |
| 571 | exit() |
| 572 | |
| 573 | status, msg = create_user(data) |
| 574 | if status: |
| 575 | _user = ManageUsers.get_users_from_db( |
| 576 | username=data['email'], |
| 577 | auth_source=data['auth_source'], |
| 578 | console=console) |
| 579 | else: |
| 580 | print(SOMETHING_WENT_WRONG + str(msg)) |
| 581 | |
| 582 | def get_user(username=None, auth_source=INTERNAL): |
| 583 | app = create_app(config.APP_NAME + '-cli') |
no test coverage detected