Commit 4fe34cbd authored by Martin Mareš's avatar Martin Mareš
Browse files

New CLI command for creating API keys

parent f333257a
......@@ -1619,6 +1619,27 @@ def cli_add_teacher(course_ident, student):
def cli_add_api_key(course_ident, teacher):
"""Create an API key for access to a given course."""
teacher_user = cli_find_user(teacher)
course = cli_find_course(course_ident)
key = secrets.token_hex(16)
INSERT INTO owl_api_keys(uid, cid, key)
VALUES (%s, %s, %s)
(teacher_user.uid, course.cid, key))
### Sending notifications ###
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment