Skip to content
Snippets Groups Projects
Commit 8aa922af authored by Mark Tearle's avatar Mark Tearle
Browse files

Added update-api-key call

parent e0ec61b9
Branches
No related merge requests found
......@@ -220,21 +220,35 @@ $leaf->post('/update-api-key', function () use($leaf) {
// Will update API key
//
// Will email to your UCC email address noting that the API key has been updated
$config=get_config();
$username = $leaf->request->get('username');
$api_key = $leaf->request->get('api_key');
$new_api_key = $leaf->request->get('new_api_key');
// Check username is valid
if ( !check_username($username) ) {
$leaf->response->json(["message" => $username." not valid"],200);
return;
}
// Check API key
if ( !check_api_key($config, $username, $api_key) ) {
$leaf->response->json(["message" => "API key for " .$username." not valid"],200);
return;
}
// Encrypt API key
// Stick API key encrypted into the DNS
$u = update_desec_txt($config, $username, encrypt_api_key($new_api_key));
$leaf->response->json(["message" => $username." API key has been updated"],200);
// Email user to let them know API key has updated
// Email API key
email_api_key($username, "(REDACTED, set by user)");
});
$leaf->post('/update-challenge', function () use($leaf) {
......
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