routes.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  7. * @author Christopher Schäpers <kondou@ts.unde.re>
  8. * @author Christoph Wurst <christoph@owncloud.com>
  9. * @author Georg Ehrke <georg@owncloud.com>
  10. * @author Lukas Reschke <lukas@statuscode.ch>
  11. * @author Morris Jobke <hey@morrisjobke.de>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Thomas Müller <thomas.mueller@tmit.eu>
  14. * @author Thomas Tanghus <thomas@tanghus.net>
  15. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  16. * @author Vincent Petry <pvince81@owncloud.com>
  17. *
  18. * @license AGPL-3.0
  19. *
  20. * This code is free software: you can redistribute it and/or modify
  21. * it under the terms of the GNU Affero General Public License, version 3,
  22. * as published by the Free Software Foundation.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU Affero General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU Affero General Public License, version 3,
  30. * along with this program. If not, see <http://www.gnu.org/licenses/>
  31. *
  32. */
  33. use OC\Core\Application;
  34. $application = new Application();
  35. $application->registerRoutes($this, [
  36. 'routes' => [
  37. ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
  38. ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
  39. ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
  40. ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
  41. ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
  42. ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
  43. ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
  44. ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
  45. ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
  46. ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
  47. ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
  48. ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
  49. ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
  50. ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
  51. ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'],
  52. ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
  53. ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
  54. ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
  55. ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
  56. ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
  57. ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'],
  58. ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
  59. ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
  60. ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
  61. ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
  62. ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
  63. ],
  64. 'ocs' => [
  65. ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
  66. ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
  67. ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
  68. ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
  69. ],
  70. ]);
  71. // Post installation check
  72. /** @var $this OCP\Route\IRouter */
  73. // Core ajax actions
  74. // Search
  75. $this->create('search_ajax_search', '/core/search')
  76. ->actionInclude('core/search/ajax/search.php');
  77. // Routing
  78. $this->create('core_ajax_update', '/core/ajax/update.php')
  79. ->actionInclude('core/ajax/update.php');
  80. // File routes
  81. $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) {
  82. $app = new \OCA\Files\AppInfo\Application($urlParams);
  83. $app->dispatch('ViewController', 'index');
  84. });
  85. // Call routes
  86. /**
  87. * @suppress PhanUndeclaredClassConstant
  88. * @suppress PhanUndeclaredClassMethod
  89. */
  90. $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) {
  91. if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) {
  92. $app = new \OCA\Spreed\AppInfo\Application($urlParams);
  93. $app->dispatch('PageController', 'index');
  94. } else {
  95. throw new \OC\HintException('App spreed is not enabled');
  96. }
  97. });
  98. // Sharing routes
  99. $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) {
  100. if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
  101. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  102. $app->dispatch('ShareController', 'showShare');
  103. } else {
  104. throw new \OC\HintException('App file sharing is not enabled');
  105. }
  106. });
  107. $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) {
  108. if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
  109. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  110. $app->dispatch('ShareController', 'authenticate');
  111. } else {
  112. throw new \OC\HintException('App file sharing is not enabled');
  113. }
  114. });
  115. $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) {
  116. if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
  117. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  118. $app->dispatch('ShareController', 'showAuthenticate');
  119. } else {
  120. throw new \OC\HintException('App file sharing is not enabled');
  121. }
  122. });
  123. $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) {
  124. if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
  125. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  126. $app->dispatch('ShareController', 'downloadShare');
  127. } else {
  128. throw new \OC\HintException('App file sharing is not enabled');
  129. }
  130. });
  131. // used for heartbeat
  132. $this->create('heartbeat', '/heartbeat')->action(function(){
  133. // do nothing
  134. });