Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Drop user only if successfully created

  • Loading branch information...
commit 2b472a5c106de7d0b6fea51927e86d6802016d0f 1 parent 112c9b3
@vrana authored
Showing with 5 additions and 3 deletions.
  1. +4 −2 adminer/user.inc.php
  2. +1 −1  tests/15-privileges.html
View
6 adminer/user.inc.php
@@ -51,8 +51,10 @@
if ($_POST["drop"]) {
query_redirect("DROP USER $old_user", ME . "privileges=", lang('User has been dropped.'));
} else {
+ $created = false;
if ($old_user != $new_user) {
- $error = !queries(($connection->server_info < 5 ? "GRANT USAGE ON *.* TO" : "CREATE USER") . " $new_user IDENTIFIED BY" . ($_POST["hashed"] ? " PASSWORD" : "") . " $pass");
+ $created = queries(($connection->server_info < 5 ? "GRANT USAGE ON *.* TO" : "CREATE USER") . " $new_user IDENTIFIED BY" . ($_POST["hashed"] ? " PASSWORD" : "") . " $pass");
+ $error = !$created;
} elseif ($_POST["pass"] != $old_pass || !$_POST["hashed"]) {
queries("SET PASSWORD FOR $new_user = " . ($_POST["hashed"] ? $pass : "PASSWORD($pass)"));
}
@@ -93,7 +95,7 @@
}
}
queries_redirect(ME . "privileges=", (isset($_GET["host"]) ? lang('User has been altered.') : lang('User has been created.')), !$error);
- if ($old_user != $new_user) {
+ if ($created) {
// delete new user in case of an error
$connection->query("DROP USER $new_user");
}
View
2  tests/15-privileges.html
@@ -108,7 +108,7 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>//div[@id='content']/table/tbody/tr[td[2]='adminer_test']/td[1]/a</td>
+ <td>//div[@id='content']/form/table/tbody/tr[td[2]='adminer_test']/td[3]/a</td>
<td></td>
</tr>
<tr>
Please sign in to comment.
Something went wrong with that request. Please try again.