AddUserAction.class.php 605 B

12345678910111213141516171819202122232425
  1. <?php
  2. class AddUserAction implements IAction {
  3. public function execute() {
  4. if(!Authorize::isLoggedIn() || !Authorize::hasPermission()) {
  5. return array("error" => "Access not authorized");
  6. }
  7. $username = $_POST['username'];
  8. $displayName = $_POST['display_name'];
  9. $password = $_POST['password'];
  10. //TODO: scrub inputs
  11. $passwordHash = hash("sha256", $password);
  12. $sql = "INSERT INTO users (username, password, display_name)
  13. VALUES
  14. (:username, :passwordhash, :display_name);";
  15. throw new NotImplementedException();
  16. //TODO: write record
  17. //$this->database->exec($sql);
  18. }
  19. }