Skip to content

Commit

Permalink
Make sure user is active and has perms for updates
Browse files Browse the repository at this point in the history
We need to make sure the user is both active and has permissions to
do updates.
  • Loading branch information
nkukard committed Apr 3, 2014
1 parent 612032f commit 4ef629e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion dynamic_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,27 @@ function status_exit($status) {
return status_exit('notfqdn');
}

$user_query = "SELECT id FROM users WHERE username='$username' and password='$password'";
$user_query = "
SELECT
users.id
FROM
users, perm_templ, perm_templ_items, perm_items
WHERE
users.username = '$username'
AND users.password = '$password'
AND users.active = 1
AND perm_templ.id = users.perm_templ
AND perm_templ_items.templ_id = perm_templ.id
AND perm_items.id = perm_templ_items.perm_id
AND (
perm_items.name = 'zone_content_edit_own'
OR perm_items.name = 'zone_content_edit_others'
)
";
$user = $db->queryRow($user_query);
if (!$user) {
return status_exit('badauth');
}

$zones_query = "SELECT domain_id FROM zones WHERE owner='{$user["id"]}'";
$zones_result = $db->query($zones_query);
Expand Down

0 comments on commit 4ef629e

Please sign in to comment.