If we login via the apikey, show it in the session

If we add a zone via the api, and the owner doesn't exist yet, create it.
This commit is contained in:
Mark Schouten 2014-09-26 14:02:22 +02:00
parent 262e3c76a8
commit 7f35f25869
2 changed files with 20 additions and 1 deletions

View file

@ -118,6 +118,13 @@ function add_db_zone($zone, $owner) {
if (_valid_label($zone) === FALSE) {
jtable_respond(null, 'error', "$zone is not a valid zonename");
}
if (is_apiuser()) {
if (!get_user_info($owner)) {
add_user($owner);
}
}
$db = get_db();
$q = $db->prepare("INSERT OR REPLACE INTO zones (zone, owner) VALUES (?, (SELECT id FROM users WHERE emailaddress = ?))");
$q->bindValue(1, $zone, SQLITE3_TEXT);