Register.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace dokuwiki\Action;
  3. use dokuwiki\Action\Exception\ActionAbort;
  4. use dokuwiki\Action\Exception\ActionDisabledException;
  5. use dokuwiki\Extension\AuthPlugin;
  6. use dokuwiki\Ui;
  7. /**
  8. * Class Register
  9. *
  10. * Self registering a new user
  11. *
  12. * @package dokuwiki\Action
  13. */
  14. class Register extends AbstractAclAction
  15. {
  16. /** @inheritdoc */
  17. public function minimumPermission()
  18. {
  19. return AUTH_NONE;
  20. }
  21. /** @inheritdoc */
  22. public function checkPreconditions()
  23. {
  24. parent::checkPreconditions();
  25. /** @var AuthPlugin $auth */
  26. global $auth;
  27. global $conf;
  28. if (isset($conf['openregister']) && !$conf['openregister']) throw new ActionDisabledException();
  29. if (!$auth->canDo('addUser')) throw new ActionDisabledException();
  30. }
  31. /** @inheritdoc */
  32. public function preProcess()
  33. {
  34. if (register()) { // FIXME could be moved from auth to here
  35. throw new ActionAbort('login');
  36. }
  37. }
  38. /** @inheritdoc */
  39. public function tplContent()
  40. {
  41. (new Ui\UserRegister)->show();
  42. }
  43. }