Project import generated by Copybara.

GitOrigin-RevId: 63746295f1a5ab5a619056791995793d65529e62
diff --git a/src/doadduser.php b/src/doadduser.php
new file mode 100644
index 0000000..af0951c
--- /dev/null
+++ b/src/doadduser.php
@@ -0,0 +1,33 @@
+<?php
+require_once("core.php");
+security::checkType(security::ADMIN);
+
+if (!security::checkParams("POST", [
+  ["username", security::PARAM_NEMPTY],
+  ["name", security::PARAM_NEMPTY],
+  ["dni", security::PARAM_ISSET],
+  ["email", security::PARAM_ISEMAILOREMPTY],
+  ["category", security::PARAM_NEMPTY],
+  ["password", security::PARAM_NEMPTY],
+  ["type", security::PARAM_ISSET]
+])) {
+  security::go("users.php?msg=empty");
+}
+
+if (!security::passwordIsGoodEnough($_POST["password"])) security::go("users.php?msg=weakpassword");
+
+$username = $_POST["username"];
+$name = $_POST["name"];
+$dni = $_POST["dni"];
+$email = $_POST["email"];
+$category = (int)$_POST["category"];
+$password_hash = password_hash($_POST["password"], PASSWORD_DEFAULT);
+$type = (int)$_POST["type"];
+
+if (!security::isAllowed($type)) security::go("users.php?msg=unexpected");
+
+if (people::add($username, $name, $dni, $email, $category, $password_hash, $type)) {
+  security::go("users.php?msg=added");
+} else {
+  security::go("users.php?msg=unexpected");
+}