web.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /*
  3. * Registra todas las rutas y middlewares del sitio web.
  4. */
  5. $app->use('', [
  6. '\App\Middlewares\Web\AuthMiddleware@verify',
  7. '\App\Middlewares\Web\AuthMiddleware@redirect'
  8. ]);
  9. $app->use('login', [
  10. '\App\Middlewares\Web\AuthMiddleware@redirect',
  11. '\App\Middlewares\Web\CsrfMiddleware@generate'
  12. ]);
  13. $app->use('login/action', [
  14. '\App\Middlewares\Web\AuthMiddleware@redirect',
  15. '\App\Middlewares\Web\CsrfMiddleware@verify'
  16. ]);
  17. $app->use('tags/new', [
  18. '\App\Middlewares\Web\AuthMiddleware@verify',
  19. '\App\Middlewares\Web\CsrfMiddleware@generate'
  20. ]);
  21. $app->use('tags/create', [
  22. '\App\Middlewares\Web\AuthMiddleware@verify',
  23. '\App\Middlewares\Web\CsrfMiddleware@verify'
  24. ]);
  25. $app->use('tags', '\App\Middlewares\Web\AuthMiddleware@verify');
  26. $app->use('tags/edit/:uuid', [
  27. '\App\Middlewares\Web\AuthMiddleware@verify',
  28. '\App\Middlewares\Web\CsrfMiddleware@generate'
  29. ]);
  30. $app->use('tags/update/:uuid', [
  31. '\App\Middlewares\Web\AuthMiddleware@verify',
  32. '\App\Middlewares\Web\CsrfMiddleware@verify'
  33. ]);
  34. $app->use('tags/delete/:uuid', '\App\Middlewares\Web\AuthMiddleware@verify');
  35. $app->use('notes/new', [
  36. '\App\Middlewares\Web\AuthMiddleware@verify',
  37. '\App\Middlewares\Web\CsrfMiddleware@generate'
  38. ]);
  39. $app->use('notes/create', [
  40. '\App\Middlewares\Web\AuthMiddleware@verify',
  41. '\App\Middlewares\Web\CsrfMiddleware@verify'
  42. ]);
  43. $app->use('notes', '\App\Middlewares\Web\AuthMiddleware@verify');
  44. $app->use('notes/:uuid', '\App\Middlewares\Web\AuthMiddleware@verify');
  45. $app->use('notes/edit/:uuid', [
  46. '\App\Middlewares\Web\AuthMiddleware@verify',
  47. '\App\Middlewares\Web\CsrfMiddleware@generate'
  48. ]);
  49. $app->use('notes/update/:uuid', [
  50. '\App\Middlewares\Web\AuthMiddleware@verify',
  51. '\App\Middlewares\Web\CsrfMiddleware@verify'
  52. ]);
  53. $app->use('notes/delete/:uuid', '\App\Middlewares\Web\AuthMiddleware@verify');
  54. $app->use('profile/edit', [
  55. '\App\Middlewares\Web\AuthMiddleware@verify',
  56. '\App\Middlewares\Web\CsrfMiddleware@generate'
  57. ]);
  58. $app->use('profile/update', [
  59. '\App\Middlewares\Web\AuthMiddleware@verify',
  60. '\App\Middlewares\Web\CsrfMiddleware@verify'
  61. ]);
  62. $app->use('users/new', [
  63. '\App\Middlewares\Web\AuthMiddleware@verify',
  64. '\App\Middlewares\Web\RoleMiddleware@isAdmin',
  65. '\App\Middlewares\Web\CsrfMiddleware@generate'
  66. ]);
  67. $app->use('users/create', [
  68. '\App\Middlewares\Web\AuthMiddleware@verify',
  69. '\App\Middlewares\Web\RoleMiddleware@isAdmin',
  70. '\App\Middlewares\Web\CsrfMiddleware@verify'
  71. ]);
  72. $app->use('users', [
  73. '\App\Middlewares\Web\AuthMiddleware@verify',
  74. '\App\Middlewares\Web\RoleMiddleware@isAdmin'
  75. ]);
  76. $app->use('users/edit/:uuid', [
  77. '\App\Middlewares\Web\AuthMiddleware@verify',
  78. '\App\Middlewares\Web\RoleMiddleware@isAdmin',
  79. '\App\Middlewares\Web\CsrfMiddleware@generate'
  80. ]);
  81. $app->use('users/update/:uuid', [
  82. '\App\Middlewares\Web\AuthMiddleware@verify',
  83. '\App\Middlewares\Web\RoleMiddleware@isAdmin',
  84. '\App\Middlewares\Web\CsrfMiddleware@verify'
  85. ]);
  86. $app->use('users/delete/:uuid', [
  87. '\App\Middlewares\Web\AuthMiddleware@verify',
  88. '\App\Middlewares\Web\RoleMiddleware@isAdmin'
  89. ]);
  90. /*
  91. * Registro de rutas.
  92. */
  93. $app->get('', '\App\Controllers\Web\PageController@index');
  94. $app->get('login', '\App\Controllers\Web\AuthController@loginView');
  95. $app->post('login/action', '\App\Controllers\Web\AuthController@loginAction');
  96. $app->get('logout', '\App\Controllers\Web\AuthController@logout');
  97. $app->get('tags/new', '\App\Controllers\Web\TagController@new');
  98. $app->post('tags/create', '\App\Controllers\Web\TagController@create');
  99. $app->get('tags', '\App\Controllers\Web\TagController@index');
  100. $app->get('tags/edit/:uuid', '\App\Controllers\Web\TagController@edit');
  101. $app->post('tags/update/:uuid', '\App\Controllers\Web\TagController@update');
  102. $app->get('tags/delete/:uuid', '\App\Controllers\Web\TagController@delete');
  103. $app->get('notes/new', '\App\Controllers\Web\NoteController@new');
  104. $app->post('notes/create', '\App\Controllers\Web\NoteController@create');
  105. $app->get('notes', '\App\Controllers\Web\NoteController@index');
  106. $app->get('notes/:uuid', '\App\Controllers\Web\NoteController@show');
  107. $app->get('notes/edit/:uuid', '\App\Controllers\Web\NoteController@edit');
  108. $app->post('notes/update/:uuid', '\App\Controllers\Web\NoteController@update');
  109. $app->get('notes/delete/:uuid', '\App\Controllers\Web\NoteController@delete');
  110. $app->get('profile/edit', '\App\Controllers\Web\ProfileController@edit');
  111. $app->post('profile/update', '\App\Controllers\Web\ProfileController@update');
  112. $app->get('users/new', '\App\Controllers\Web\UserController@new');
  113. $app->post('users/create', '\App\Controllers\Web\UserController@create');
  114. $app->get('users', '\App\Controllers\Web\UserController@index');
  115. $app->get('users/edit/:uuid', '\App\Controllers\Web\UserController@edit');
  116. $app->post('users/update/:uuid', '\App\Controllers\Web\UserController@update');
  117. $app->get('users/delete/:uuid', '\App\Controllers\Web\UserController@delete');
  118. $app->all(':wildcard', '\App\Controllers\Web\PageController@error404');