Removes a user from the system. Returns: On success, a JSON data structure with a property "username" (str). Returns error object on failure.
()
| 195 | @api_blueprint.route('/user', methods=['DELETE']) |
| 196 | @required_auth(auth.Role.ADMIN) |
| 197 | def user_delete(): |
| 198 | """Removes a user from the system. |
| 199 | |
| 200 | Returns: |
| 201 | On success, a JSON data structure with a property "username" (str). |
| 202 | Returns error object on failure. |
| 203 | """ |
| 204 | try: |
| 205 | username = request_parsers.delete_user.parse_delete(flask.request) |
| 206 | except request_parsers.errors.Error as e: |
| 207 | return json_response.error(e), 400 |
| 208 | |
| 209 | if username == session.get_username() and len(auth.get_all_accounts()) > 1: |
| 210 | return json_response.error( |
| 211 | UnableToDeleteCurrentUserError( |
| 212 | 'Unable to remove currently logged-in user while other users' |
| 213 | ' exist')), 409 |
| 214 | |
| 215 | try: |
| 216 | auth.delete_account(username) |
| 217 | except db.users.UserDoesNotExistError as e: |
| 218 | return json_response.error(e), 404 |
| 219 | |
| 220 | if username == session.get_username(): |
| 221 | session.logout() |
| 222 | |
| 223 | return json_response.success({'username': username}) |
| 224 | |
| 225 | |
| 226 | @api_blueprint.route('/auth', methods=['GET']) |
nothing calls this directly
no test coverage detected