requesttoken.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * ownCloud
  4. * @author Christian Reiner
  5. * @copyright 2011-2012 Christian Reiner <foss@christian-reiner.info>
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  9. * License as published by the Free Software Foundation; either
  10. * version 3 of the license, or any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public
  18. * License along with this library.
  19. * If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * @file core/ajax/requesttoken.php
  24. * @brief Ajax method to retrieve a fresh request protection token for ajax calls
  25. * @return json: success/error state indicator including a fresh request token
  26. * @author Christian Reiner
  27. */
  28. require_once '../../lib/base.php';
  29. // don't load apps or filesystem for this task
  30. $RUNTIME_NOAPPS = TRUE;
  31. $RUNTIME_NOSETUPFS = TRUE;
  32. // Sanity checks
  33. // using OCP\JSON::callCheck() below protects the token refreshing itself.
  34. //OCP\JSON::callCheck ( );
  35. OCP\JSON::checkLoggedIn ( );
  36. // hand out a fresh token
  37. OCP\JSON::success ( array ( 'token' => OCP\Util::callRegister() ) );
  38. ?>