MCPcopy Create free account
hub / github.com/tiny-pilot/tinypilot / user_post

Function user_post

app/api.py:108–127  ·  view source on GitHub ↗

Adds a new user to the system. Returns: On success, a JSON data structure with a property "username" (str). Returns error object on failure.

()

Source from the content-addressed store, hash-verified

106@api_blueprint.route('/user', methods=['POST'])
107@required_auth(auth.Role.ADMIN)
108def 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'])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected