Adds a new user to the system. Returns: On success, a JSON data structure with a property "username" (str). Returns error object on failure.
()
| 106 | @api_blueprint.route('/user', methods=['POST']) |
| 107 | @required_auth(auth.Role.ADMIN) |
| 108 | def user_post(): |
| 109 | """Adds a new user to the system. |
| 110 | |
| 111 | Returns: |
| 112 | On success, a JSON data structure with a property "username" (str). |
| 113 | Returns error object on failure. |
| 114 | """ |
| 115 | try: |
| 116 | username, password, role = request_parsers.create_user.parse( |
| 117 | flask.request) |
| 118 | except request_parsers.errors.Error as e: |
| 119 | return json_response.error(e), 400 |
| 120 | |
| 121 | try: |
| 122 | auth.register(username, password, role) |
| 123 | except db.users.UserAlreadyExistsError as e: |
| 124 | return json_response.error(e), 409 |
| 125 | if len(auth.get_all_accounts()) == 1: |
| 126 | session.login(username) |
| 127 | return json_response.success({'username': username}) |
| 128 | |
| 129 | |
| 130 | @api_blueprint.route('/currentUser/password', methods=['PUT']) |
nothing calls this directly
no outgoing calls
no test coverage detected