@strapi/admin 4.15.1 → 4.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/dist/_chunks/{AuthenticatedApp-092ef2be.js → AuthenticatedApp-d1e28164.js} +30 -30
  2. package/dist/_chunks/{AuthenticatedApp-092ef2be.js.map → AuthenticatedApp-d1e28164.js.map} +1 -1
  3. package/dist/_chunks/{AuthenticatedApp-b0ada7e9.mjs → AuthenticatedApp-fd7e406d.mjs} +30 -30
  4. package/dist/_chunks/{AuthenticatedApp-b0ada7e9.mjs.map → AuthenticatedApp-fd7e406d.mjs.map} +1 -1
  5. package/dist/_chunks/{HomePage-5798ba6f.mjs → HomePage-2a7f678a.mjs} +7 -8
  6. package/dist/_chunks/{HomePage-5798ba6f.mjs.map → HomePage-2a7f678a.mjs.map} +1 -1
  7. package/dist/_chunks/{HomePage-5ae473e6.js → HomePage-2ac5c213.js} +7 -8
  8. package/dist/_chunks/{HomePage-5ae473e6.js.map → HomePage-2ac5c213.js.map} +1 -1
  9. package/dist/_chunks/{HomePage-bdcb51be.js → HomePage-616a2985.js} +12 -13
  10. package/dist/_chunks/HomePage-616a2985.js.map +1 -0
  11. package/dist/_chunks/{HomePage-a3cc32d2.mjs → HomePage-ded37c60.mjs} +12 -13
  12. package/dist/_chunks/HomePage-ded37c60.mjs.map +1 -0
  13. package/dist/_chunks/{InstalledPluginsPage-cc2d6a36.js → InstalledPluginsPage-189010c1.js} +10 -12
  14. package/dist/_chunks/{InstalledPluginsPage-cc2d6a36.js.map → InstalledPluginsPage-189010c1.js.map} +1 -1
  15. package/dist/_chunks/{InstalledPluginsPage-6284aaff.mjs → InstalledPluginsPage-afa9edc3.mjs} +10 -12
  16. package/dist/_chunks/{InstalledPluginsPage-6284aaff.mjs.map → InstalledPluginsPage-afa9edc3.mjs.map} +1 -1
  17. package/dist/_chunks/{index-305a03f4.mjs → Login-02ddabf7.mjs} +25 -29
  18. package/dist/_chunks/Login-02ddabf7.mjs.map +1 -0
  19. package/dist/_chunks/{index-137490ba.js → Login-28127829.js} +25 -30
  20. package/dist/_chunks/Login-28127829.js.map +1 -0
  21. package/dist/_chunks/{MarketplacePage-7dee72f5.mjs → MarketplacePage-40f76f3d.mjs} +6 -8
  22. package/dist/_chunks/{MarketplacePage-7dee72f5.mjs.map → MarketplacePage-40f76f3d.mjs.map} +1 -1
  23. package/dist/_chunks/{MarketplacePage-209ec658.js → MarketplacePage-946134e6.js} +6 -8
  24. package/dist/_chunks/{MarketplacePage-209ec658.js.map → MarketplacePage-946134e6.js.map} +1 -1
  25. package/dist/_chunks/{ProfilePage-26c14ba4.mjs → ProfilePage-4c94e332.mjs} +7 -9
  26. package/dist/_chunks/{ProfilePage-26c14ba4.mjs.map → ProfilePage-4c94e332.mjs.map} +1 -1
  27. package/dist/_chunks/{ProfilePage-4f8c127b.js → ProfilePage-6506e401.js} +7 -9
  28. package/dist/_chunks/{ProfilePage-4f8c127b.js.map → ProfilePage-6506e401.js.map} +1 -1
  29. package/dist/_chunks/{SSOProviders-1d062c95.mjs → SSOProviders-62bfad92.mjs} +29 -61
  30. package/dist/_chunks/SSOProviders-62bfad92.mjs.map +1 -0
  31. package/dist/_chunks/{SSOProviders-1ef0a89e.js → SSOProviders-b395a4e6.js} +28 -80
  32. package/dist/_chunks/SSOProviders-b395a4e6.js.map +1 -0
  33. package/dist/_chunks/{build-f36bfc97.js → build-55ba3e68.js} +4 -2
  34. package/dist/_chunks/{build-f36bfc97.js.map → build-55ba3e68.js.map} +1 -1
  35. package/dist/_chunks/{build-e1ca35da.mjs → build-b67ecc59.mjs} +4 -2
  36. package/dist/_chunks/{build-e1ca35da.mjs.map → build-b67ecc59.mjs.map} +1 -1
  37. package/dist/_chunks/{constants-70e05152.js → constants-42f4f7b3.js} +6 -6
  38. package/dist/_chunks/{constants-70e05152.js.map → constants-42f4f7b3.js.map} +1 -1
  39. package/dist/_chunks/{constants-921eda17.mjs → constants-6ecddc43.mjs} +43 -15
  40. package/dist/_chunks/constants-6ecddc43.mjs.map +1 -0
  41. package/dist/_chunks/{constants-727a113c.js → constants-733b0568.js} +26 -26
  42. package/dist/_chunks/constants-733b0568.js.map +1 -0
  43. package/dist/_chunks/{constants-86aa3e70.js → constants-7596f6f3.js} +60 -13
  44. package/dist/_chunks/constants-7596f6f3.js.map +1 -0
  45. package/dist/_chunks/{constants-32975b2e.js → constants-82e97fee.js} +11 -12
  46. package/dist/_chunks/{constants-32975b2e.js.map → constants-82e97fee.js.map} +1 -1
  47. package/dist/_chunks/{constants-90c20a6f.mjs → constants-952c50be.mjs} +11 -12
  48. package/dist/_chunks/{constants-90c20a6f.mjs.map → constants-952c50be.mjs.map} +1 -1
  49. package/dist/_chunks/{constants-9de7641c.mjs → constants-c0280aed.mjs} +28 -28
  50. package/dist/_chunks/constants-c0280aed.mjs.map +1 -0
  51. package/dist/_chunks/{constants-a773ff9b.js → constants-c9fce26f.js} +13 -12
  52. package/dist/_chunks/{constants-a773ff9b.js.map → constants-c9fce26f.js.map} +1 -1
  53. package/dist/_chunks/{constants-6157f648.mjs → constants-cbadfd36.mjs} +6 -6
  54. package/dist/_chunks/{constants-6157f648.mjs.map → constants-cbadfd36.mjs.map} +1 -1
  55. package/dist/_chunks/{constants-27319180.mjs → constants-cd1acf1b.mjs} +13 -12
  56. package/dist/_chunks/{constants-27319180.mjs.map → constants-cd1acf1b.mjs.map} +1 -1
  57. package/dist/_chunks/{develop-513c9644.js → develop-69e28e61.js} +4 -2
  58. package/dist/_chunks/{develop-513c9644.js.map → develop-69e28e61.js.map} +1 -1
  59. package/dist/_chunks/{develop-e45b460e.mjs → develop-d97e7494.mjs} +4 -2
  60. package/dist/_chunks/{develop-e45b460e.mjs.map → develop-d97e7494.mjs.map} +1 -1
  61. package/dist/_chunks/formatAPIErrors-b599cf27.js +20 -0
  62. package/dist/_chunks/formatAPIErrors-b599cf27.js.map +1 -0
  63. package/dist/_chunks/formatAPIErrors-db6ed675.mjs +21 -0
  64. package/dist/_chunks/formatAPIErrors-db6ed675.mjs.map +1 -0
  65. package/dist/_chunks/{index-af69bc98.mjs → index-01dfec54.mjs} +11 -11
  66. package/dist/_chunks/{index-af69bc98.mjs.map → index-01dfec54.mjs.map} +1 -1
  67. package/dist/_chunks/{index-fcd5bc14.mjs → index-0ed0c104.mjs} +14 -13
  68. package/dist/_chunks/{index-fcd5bc14.mjs.map → index-0ed0c104.mjs.map} +1 -1
  69. package/dist/_chunks/{index-1f1e2465.js → index-13a78498.js} +9 -11
  70. package/dist/_chunks/{index-1f1e2465.js.map → index-13a78498.js.map} +1 -1
  71. package/dist/_chunks/{index-6b9e3d60.js → index-150ec200.js} +9 -10
  72. package/dist/_chunks/{index-6b9e3d60.js.map → index-150ec200.js.map} +1 -1
  73. package/dist/_chunks/{index-b2257157.js → index-17acbe23.js} +49 -12
  74. package/dist/_chunks/index-17acbe23.js.map +1 -0
  75. package/dist/_chunks/{index-f5342ea5.js → index-17fbff58.js} +14 -13
  76. package/dist/_chunks/{index-f5342ea5.js.map → index-17fbff58.js.map} +1 -1
  77. package/dist/_chunks/{index-bb8093ea.mjs → index-18155022.mjs} +12 -12
  78. package/dist/_chunks/{index-bb8093ea.mjs.map → index-18155022.mjs.map} +1 -1
  79. package/dist/_chunks/{index-e22d1a84.mjs → index-22993544.mjs} +14 -13
  80. package/dist/_chunks/{index-e22d1a84.mjs.map → index-22993544.mjs.map} +1 -1
  81. package/dist/_chunks/{index-16030b74.js → index-2f4b78ee.js} +3 -3
  82. package/dist/_chunks/index-2f4b78ee.js.map +1 -0
  83. package/dist/_chunks/{index-35e4bad6.mjs → index-30933e3e.mjs} +8 -9
  84. package/dist/_chunks/{index-35e4bad6.mjs.map → index-30933e3e.mjs.map} +1 -1
  85. package/dist/_chunks/{index-928b18d2.mjs → index-31227291.mjs} +3 -3
  86. package/dist/_chunks/{index-928b18d2.mjs.map → index-31227291.mjs.map} +1 -1
  87. package/dist/_chunks/{index-24189ec9.js → index-3b888524.js} +6 -6
  88. package/dist/_chunks/{index-24189ec9.js.map → index-3b888524.js.map} +1 -1
  89. package/dist/_chunks/{index-5752584c.mjs → index-44360544.mjs} +182 -76
  90. package/dist/_chunks/index-44360544.mjs.map +1 -0
  91. package/dist/_chunks/{index-be2ca313.mjs → index-45ae7be1.mjs} +13 -13
  92. package/dist/_chunks/{index-be2ca313.mjs.map → index-45ae7be1.mjs.map} +1 -1
  93. package/dist/_chunks/{index-62b4b3fc.js → index-470a72bf.js} +11 -11
  94. package/dist/_chunks/{index-62b4b3fc.js.map → index-470a72bf.js.map} +1 -1
  95. package/dist/_chunks/{index-00202c8a.mjs → index-4a46c368.mjs} +13 -12
  96. package/dist/_chunks/{index-00202c8a.mjs.map → index-4a46c368.mjs.map} +1 -1
  97. package/dist/_chunks/{index-332f319e.mjs → index-52b70b56.mjs} +8 -10
  98. package/dist/_chunks/{index-332f319e.mjs.map → index-52b70b56.mjs.map} +1 -1
  99. package/dist/_chunks/{index-5ad8482b.mjs → index-55f9b6b3.mjs} +7 -7
  100. package/dist/_chunks/{index-5ad8482b.mjs.map → index-55f9b6b3.mjs.map} +1 -1
  101. package/dist/_chunks/{index-6cc54f3b.mjs → index-59e31a9f.mjs} +8 -9
  102. package/dist/_chunks/{index-6cc54f3b.mjs.map → index-59e31a9f.mjs.map} +1 -1
  103. package/dist/_chunks/{index-1e973c03.mjs → index-5df8a59e.mjs} +14 -13
  104. package/dist/_chunks/{index-1e973c03.mjs.map → index-5df8a59e.mjs.map} +1 -1
  105. package/dist/_chunks/{index-34de382e.mjs → index-60a57d31.mjs} +688 -824
  106. package/dist/_chunks/index-60a57d31.mjs.map +1 -0
  107. package/dist/_chunks/{index-77e0e5d7.js → index-62264743.js} +8 -7
  108. package/dist/_chunks/{index-77e0e5d7.js.map → index-62264743.js.map} +1 -1
  109. package/dist/_chunks/{index-4565fcbd.js → index-6931e33c.js} +3 -3
  110. package/dist/_chunks/{index-4565fcbd.js.map → index-6931e33c.js.map} +1 -1
  111. package/dist/_chunks/{index-3c58de6f.js → index-748f8264.js} +14 -13
  112. package/dist/_chunks/{index-3c58de6f.js.map → index-748f8264.js.map} +1 -1
  113. package/dist/_chunks/{index-bdfc1149.mjs → index-768b7de9.mjs} +49 -12
  114. package/dist/_chunks/index-768b7de9.mjs.map +1 -0
  115. package/dist/_chunks/{index-1763a04f.js → index-7739ddf5.js} +8 -9
  116. package/dist/_chunks/{index-1763a04f.js.map → index-7739ddf5.js.map} +1 -1
  117. package/dist/_chunks/{index-89d27faa.js → index-794eb0b6.js} +14 -13
  118. package/dist/_chunks/{index-89d27faa.js.map → index-794eb0b6.js.map} +1 -1
  119. package/dist/_chunks/{index-f448aed2.js → index-7e9cd960.js} +13 -12
  120. package/dist/_chunks/{index-f448aed2.js.map → index-7e9cd960.js.map} +1 -1
  121. package/dist/_chunks/{index-0af587c3.js → index-7f642760.js} +78 -147
  122. package/dist/_chunks/index-7f642760.js.map +1 -0
  123. package/dist/_chunks/{index-56ced4ab.mjs → index-853bd239.mjs} +8 -7
  124. package/dist/_chunks/{index-56ced4ab.mjs.map → index-853bd239.mjs.map} +1 -1
  125. package/dist/_chunks/{index-b98ea3ce.mjs → index-8a4d0275.mjs} +13 -14
  126. package/dist/_chunks/{index-b98ea3ce.mjs.map → index-8a4d0275.mjs.map} +1 -1
  127. package/dist/_chunks/{index-6dbc94a9.mjs → index-9c45bda7.mjs} +6 -6
  128. package/dist/_chunks/{index-6dbc94a9.mjs.map → index-9c45bda7.mjs.map} +1 -1
  129. package/dist/_chunks/{index-4c5acc70.js → index-9eb160a3.js} +9 -10
  130. package/dist/_chunks/{index-4c5acc70.js.map → index-9eb160a3.js.map} +1 -1
  131. package/dist/_chunks/{index-51a15b27.js → index-9f155b14.js} +4 -4
  132. package/dist/_chunks/{index-51a15b27.js.map → index-9f155b14.js.map} +1 -1
  133. package/dist/_chunks/{index-066ee02e.js → index-9f50c8b0.js} +8 -10
  134. package/dist/_chunks/{index-066ee02e.js.map → index-9f50c8b0.js.map} +1 -1
  135. package/dist/_chunks/{index-284c5926.js → index-9f900c47.js} +33 -47
  136. package/dist/_chunks/index-9f900c47.js.map +1 -0
  137. package/dist/_chunks/{index-5d8d89a7.js → index-a163001f.js} +13 -13
  138. package/dist/_chunks/{index-5d8d89a7.js.map → index-a163001f.js.map} +1 -1
  139. package/dist/_chunks/{index-34a2909e.mjs → index-a3176d19.mjs} +12 -12
  140. package/dist/_chunks/{index-34a2909e.mjs.map → index-a3176d19.mjs.map} +1 -1
  141. package/dist/_chunks/{index-ea23ee9f.mjs → index-a7d28c42.mjs} +9 -11
  142. package/dist/_chunks/{index-ea23ee9f.mjs.map → index-a7d28c42.mjs.map} +1 -1
  143. package/dist/_chunks/{index-a4348f3b.js → index-a8358156.js} +12 -12
  144. package/dist/_chunks/index-a8358156.js.map +1 -0
  145. package/dist/_chunks/{index-58db145d.mjs → index-a8d13f01.mjs} +3 -3
  146. package/dist/_chunks/{index-58db145d.mjs.map → index-a8d13f01.mjs.map} +1 -1
  147. package/dist/_chunks/{index-59d22949.mjs → index-b4cc14ad.mjs} +8 -9
  148. package/dist/_chunks/{index-59d22949.mjs.map → index-b4cc14ad.mjs.map} +1 -1
  149. package/dist/_chunks/{index-6a512cec.js → index-bad666f0.js} +8 -9
  150. package/dist/_chunks/{index-6a512cec.js.map → index-bad666f0.js.map} +1 -1
  151. package/dist/_chunks/{index-53ba81f9.mjs → index-bf788868.mjs} +9 -10
  152. package/dist/_chunks/{index-53ba81f9.mjs.map → index-bf788868.mjs.map} +1 -1
  153. package/dist/_chunks/{index-da04b144.js → index-bfb5b3ab.js} +14 -13
  154. package/dist/_chunks/{index-da04b144.js.map → index-bfb5b3ab.js.map} +1 -1
  155. package/dist/_chunks/{index-cadd3ee0.js → index-c0603138.js} +4 -4
  156. package/dist/_chunks/{index-cadd3ee0.js.map → index-c0603138.js.map} +1 -1
  157. package/dist/_chunks/{index-c604806d.js → index-c3761887.js} +12 -12
  158. package/dist/_chunks/{index-c604806d.js.map → index-c3761887.js.map} +1 -1
  159. package/dist/_chunks/{index-1da8c640.mjs → index-c4d3a07b.mjs} +9 -10
  160. package/dist/_chunks/{index-1da8c640.mjs.map → index-c4d3a07b.mjs.map} +1 -1
  161. package/dist/_chunks/{index-36e0d449.mjs → index-c7386be1.mjs} +32 -45
  162. package/dist/_chunks/index-c7386be1.mjs.map +1 -0
  163. package/dist/_chunks/{index-8d4d361d.mjs → index-cc7bedec.mjs} +13 -13
  164. package/dist/_chunks/{index-8d4d361d.mjs.map → index-cc7bedec.mjs.map} +1 -1
  165. package/dist/_chunks/{index-86dfbe3a.js → index-cce8ecb6.js} +178 -72
  166. package/dist/_chunks/index-cce8ecb6.js.map +1 -0
  167. package/dist/_chunks/{index-acd6d64f.js → index-cdadc366.js} +8 -7
  168. package/dist/_chunks/{index-acd6d64f.js.map → index-cdadc366.js.map} +1 -1
  169. package/dist/_chunks/{index-48322669.mjs → index-d81f74c4.mjs} +3 -3
  170. package/dist/_chunks/index-d81f74c4.mjs.map +1 -0
  171. package/dist/_chunks/{index-b81f7273.mjs → index-d93367d2.mjs} +78 -147
  172. package/dist/_chunks/index-d93367d2.mjs.map +1 -0
  173. package/dist/_chunks/{index-85069cac.mjs → index-dace55d9.mjs} +9 -10
  174. package/dist/_chunks/{index-85069cac.mjs.map → index-dace55d9.mjs.map} +1 -1
  175. package/dist/_chunks/{index-f179c7ea.js → index-db37fbe6.js} +13 -13
  176. package/dist/_chunks/{index-f179c7ea.js.map → index-db37fbe6.js.map} +1 -1
  177. package/dist/_chunks/{index-d1620260.js → index-dcb2c919.js} +13 -14
  178. package/dist/_chunks/{index-d1620260.js.map → index-dcb2c919.js.map} +1 -1
  179. package/dist/_chunks/{index-52b5db8a.js → index-dd3259f3.js} +8 -9
  180. package/dist/_chunks/{index-52b5db8a.js.map → index-dd3259f3.js.map} +1 -1
  181. package/dist/_chunks/{index-7d40adea.mjs → index-df42dfec.mjs} +8 -7
  182. package/dist/_chunks/{index-7d40adea.mjs.map → index-df42dfec.mjs.map} +1 -1
  183. package/dist/_chunks/{index-edc9bb0b.js → index-e2663a88.js} +673 -811
  184. package/dist/_chunks/index-e2663a88.js.map +1 -0
  185. package/dist/_chunks/{index-7aed99db.js → index-e2c5346d.js} +12 -12
  186. package/dist/_chunks/{index-7aed99db.js.map → index-e2c5346d.js.map} +1 -1
  187. package/dist/_chunks/{index-e414353b.js → index-e7381e58.js} +8 -8
  188. package/dist/_chunks/{index-e414353b.js.map → index-e7381e58.js.map} +1 -1
  189. package/dist/_chunks/{index-73ba6bdd.mjs → index-e8eff6c5.mjs} +3 -3
  190. package/dist/_chunks/{index-73ba6bdd.mjs.map → index-e8eff6c5.mjs.map} +1 -1
  191. package/dist/_chunks/{index-370a4ee8.mjs → index-f69d3930.mjs} +12 -12
  192. package/dist/_chunks/index-f69d3930.mjs.map +1 -0
  193. package/dist/_chunks/{index-8ea5a488.js → index-f9e95b10.js} +9 -10
  194. package/dist/_chunks/{index-8ea5a488.js.map → index-f9e95b10.js.map} +1 -1
  195. package/dist/_chunks/{index-1b7e986c.mjs → index-fe29b1fd.mjs} +14 -13
  196. package/dist/_chunks/{index-1b7e986c.mjs.map → index-fe29b1fd.mjs.map} +1 -1
  197. package/dist/_chunks/{schema-f49c76d7.js → schema-8eebfdf9.js} +2 -2
  198. package/dist/_chunks/{schema-f49c76d7.js.map → schema-8eebfdf9.js.map} +1 -1
  199. package/dist/_chunks/{schema-a95f2514.mjs → schema-ac25a47b.mjs} +2 -2
  200. package/dist/_chunks/{schema-a95f2514.mjs.map → schema-ac25a47b.mjs.map} +1 -1
  201. package/dist/_chunks/{validateWorkflow-d051b610.mjs → validateWorkflow-2511dc85.mjs} +3 -3
  202. package/dist/_chunks/{validateWorkflow-d051b610.mjs.map → validateWorkflow-2511dc85.mjs.map} +1 -1
  203. package/dist/_chunks/{validateWorkflow-e66d7d2e.js → validateWorkflow-c0f3148d.js} +3 -3
  204. package/dist/_chunks/{validateWorkflow-e66d7d2e.js.map → validateWorkflow-c0f3148d.js.map} +1 -1
  205. package/dist/admin/index.js +9 -10
  206. package/dist/admin/index.js.map +1 -1
  207. package/dist/admin/index.mjs +9 -10
  208. package/dist/admin/index.mjs.map +1 -1
  209. package/dist/admin/src/constants.d.ts +10 -0
  210. package/dist/admin/src/contexts/admin.d.ts +2 -2
  211. package/dist/admin/src/hooks/__mocks__/useSettingsMenu.d.ts +2 -0
  212. package/dist/admin/src/hooks/useEnterprise.d.ts +6 -4
  213. package/dist/admin/src/hooks/useSettingsMenu.d.ts +24 -0
  214. package/dist/admin/src/pages/Auth/AuthPage.d.ts +6 -0
  215. package/dist/admin/src/pages/Auth/components/FieldActionWrapper.d.ts +3 -0
  216. package/dist/admin/src/pages/Auth/components/ForgotPassword.d.ts +3 -0
  217. package/dist/admin/src/pages/Auth/components/ForgotPasswordSuccess.d.ts +2 -0
  218. package/dist/admin/src/pages/Auth/components/Login.d.ts +8 -0
  219. package/dist/admin/src/pages/Auth/components/Oops.d.ts +2 -0
  220. package/dist/admin/src/pages/Auth/components/Register.d.ts +7 -0
  221. package/dist/admin/src/pages/Auth/components/ResetPassword.d.ts +3 -0
  222. package/dist/admin/src/pages/Auth/constants.d.ts +14 -0
  223. package/dist/admin/src/pages/Marketplace/hooks/useMarketplaceData.d.ts +2 -2
  224. package/dist/admin/src/types/permissions.d.ts +10 -0
  225. package/dist/cli.js +3 -1
  226. package/dist/cli.js.map +1 -1
  227. package/dist/cli.mjs +3 -1
  228. package/dist/cli.mjs.map +1 -1
  229. package/dist/ee/admin/src/constants.d.ts +3 -1
  230. package/dist/ee/admin/src/pages/AuthPage/components/Login.d.ts +3 -0
  231. package/dist/ee/admin/src/pages/AuthPage/components/Providers.d.ts +2 -0
  232. package/dist/ee/admin/src/pages/AuthPage/components/SSOProviders.d.ts +8 -0
  233. package/dist/ee/admin/src/pages/AuthPage/constants.d.ts +3 -0
  234. package/dist/ee/admin/src/pages/AuthResponse.d.ts +2 -0
  235. package/dist/ee/admin/src/pages/HomePage.d.ts +1 -1
  236. package/dist/shared/contracts/authentication.d.ts +126 -0
  237. package/dist/shared/contracts/providers.d.ts +18 -0
  238. package/package.json +21 -21
  239. package/dist/_chunks/HomePage-a3cc32d2.mjs.map +0 -1
  240. package/dist/_chunks/HomePage-bdcb51be.js.map +0 -1
  241. package/dist/_chunks/SSOProviders-1d062c95.mjs.map +0 -1
  242. package/dist/_chunks/SSOProviders-1ef0a89e.js.map +0 -1
  243. package/dist/_chunks/constants-12dfb222.mjs +0 -34
  244. package/dist/_chunks/constants-12dfb222.mjs.map +0 -1
  245. package/dist/_chunks/constants-1aea1185.js +0 -34
  246. package/dist/_chunks/constants-1aea1185.js.map +0 -1
  247. package/dist/_chunks/constants-727a113c.js.map +0 -1
  248. package/dist/_chunks/constants-86aa3e70.js.map +0 -1
  249. package/dist/_chunks/constants-921eda17.mjs.map +0 -1
  250. package/dist/_chunks/constants-9de7641c.mjs.map +0 -1
  251. package/dist/_chunks/index-0af587c3.js.map +0 -1
  252. package/dist/_chunks/index-137490ba.js.map +0 -1
  253. package/dist/_chunks/index-16030b74.js.map +0 -1
  254. package/dist/_chunks/index-284c5926.js.map +0 -1
  255. package/dist/_chunks/index-305a03f4.mjs.map +0 -1
  256. package/dist/_chunks/index-34de382e.mjs.map +0 -1
  257. package/dist/_chunks/index-36e0d449.mjs.map +0 -1
  258. package/dist/_chunks/index-370a4ee8.mjs.map +0 -1
  259. package/dist/_chunks/index-48322669.mjs.map +0 -1
  260. package/dist/_chunks/index-5752584c.mjs.map +0 -1
  261. package/dist/_chunks/index-86dfbe3a.js.map +0 -1
  262. package/dist/_chunks/index-a4348f3b.js.map +0 -1
  263. package/dist/_chunks/index-b2257157.js.map +0 -1
  264. package/dist/_chunks/index-b81f7273.mjs.map +0 -1
  265. package/dist/_chunks/index-bdfc1149.mjs.map +0 -1
  266. package/dist/_chunks/index-edc9bb0b.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { auth, useCallbackRef, Form, Link, useQuery, useNotification, useAppInfo, usePersistentState, useTracking, useAPIErrorHandler, useFetchClient, getYupInnerErrors, translatedErrors, useGuidedTour, useFocusWhenNavigate, pxToRem, LoadingIndicatorPage, TrackingProvider, prefixFileUrlWithBackendUrl, GuidedTourProvider as GuidedTourProvider$1, StrapiAppProvider, LibraryProvider, CustomFieldsProvider, AutoReloadOverlayBlockerProvider, OverlayBlockerProvider, NotificationsProvider, RBACContext, getFetchClient } from "@strapi/helper-plugin";
2
+ import { auth, useCallbackRef, translatedErrors, useFetchClient, useQuery, Form, useNotification, useAppInfo, usePersistentState, useTracking, useGuidedTour, useAPIErrorHandler, getYupInnerErrors, useFocusWhenNavigate, pxToRem, LoadingIndicatorPage, TrackingProvider, prefixFileUrlWithBackendUrl, GuidedTourProvider as GuidedTourProvider$1, StrapiAppProvider, LibraryProvider, CustomFieldsProvider, AutoReloadOverlayBlockerProvider, OverlayBlockerProvider, NotificationsProvider, RBACContext, getFetchClient } from "@strapi/helper-plugin";
3
3
  import { createRoot } from "react-dom/client";
4
4
  import { Box, Flex, SingleSelect, SingleSelectOption, FieldAction, TextInput, Main, Typography, Checkbox, Button, Field, Portal, IconButton, FieldLabel, VisuallyHidden, FieldInput, Textarea, Grid, GridItem, HeaderLayout, ContentLayout, EmptyStateLayout, LinkButton, Select, Option, TextButton, SkipToContent, DesignSystemProvider, lightTheme, darkTheme } from "@strapi/design-system";
5
5
  import invariant from "invariant";
@@ -7,26 +7,25 @@ import isFunction from "lodash/isFunction";
7
7
  import merge from "lodash/merge";
8
8
  import pick from "lodash/pick";
9
9
  import { Helmet } from "react-helmet";
10
- import { useLocation, Route, Redirect, useHistory, useRouteMatch, Switch, BrowserRouter } from "react-router-dom";
10
+ import { useLocation, Route, Redirect, useHistory, NavLink, useRouteMatch, Switch, BrowserRouter } from "react-router-dom";
11
11
  import * as React from "react";
12
- import { useState, useReducer, useEffect } from "react";
13
12
  import { IntlProvider, useIntl } from "react-intl";
14
13
  import { useDispatch, Provider, useSelector, useStore } from "react-redux";
15
14
  import { createContext } from "@radix-ui/react-context";
16
- import axios from "axios";
17
- import camelCase from "lodash/camelCase";
18
- import get from "lodash/get";
19
- import omit from "lodash/omit";
20
- import PropTypes from "prop-types";
21
- import defaultsDeep from "lodash/defaultsDeep";
22
- import styled, { useTheme, createGlobalStyle } from "styled-components";
15
+ import { Link } from "@strapi/design-system/v2";
23
16
  import { Eye, EyeStriked, Cross, ArrowRight, EmptyPictures } from "@strapi/icons";
24
17
  import { Formik, Form as Form$1 } from "formik";
25
- import * as yup from "yup";
18
+ import camelCase from "lodash/camelCase";
26
19
  import { useMutation, useQuery as useQuery$1, QueryClient, QueryClientProvider } from "react-query";
20
+ import styled, { useTheme, createGlobalStyle } from "styled-components";
21
+ import * as yup from "yup";
22
+ import { ValidationError } from "yup";
23
+ import defaultsDeep from "lodash/defaultsDeep";
24
+ import omit from "lodash/omit";
25
+ import { parse } from "qs";
27
26
  import produce from "immer";
27
+ import get from "lodash/get";
28
28
  import set from "lodash/set";
29
- import { parse } from "qs";
30
29
  import { createSelector, configureStore, combineReducers } from "@reduxjs/toolkit";
31
30
  const styles = `
32
31
  .strapi--root {
@@ -234,16 +233,79 @@ const HOOKS = {
234
233
  };
235
234
  const ACTION_SET_APP_RUNTIME_STATUS = "StrapiAdmin/APP/SET_APP_RUNTIME_STATUS";
236
235
  const ACTION_SET_ADMIN_PERMISSIONS = "StrapiAdmin/App/SET_ADMIN_PERMISSIONS";
236
+ const SETTINGS_LINKS_CE = () => ({
237
+ global: [
238
+ {
239
+ intlLabel: { id: "Settings.application.title", defaultMessage: "Overview" },
240
+ to: "/settings/application-infos",
241
+ id: "000-application-infos"
242
+ },
243
+ {
244
+ intlLabel: { id: "Settings.webhooks.title", defaultMessage: "Webhooks" },
245
+ to: "/settings/webhooks",
246
+ id: "webhooks"
247
+ },
248
+ {
249
+ intlLabel: { id: "Settings.apiTokens.title", defaultMessage: "API Tokens" },
250
+ to: "/settings/api-tokens?sort=name:ASC",
251
+ id: "api-tokens"
252
+ },
253
+ {
254
+ intlLabel: { id: "Settings.transferTokens.title", defaultMessage: "Transfer Tokens" },
255
+ to: "/settings/transfer-tokens?sort=name:ASC",
256
+ id: "transfer-tokens"
257
+ },
258
+ // If the Enterprise feature is not enabled and if the config doesn't disable it, we promote the Enterprise feature by displaying them in the settings menu.
259
+ // Disable this by adding "promoteEE: false" to your `./config/admin.js` file
260
+ ...!window.strapi.features.isEnabled(window.strapi.features.SSO) && window.strapi?.flags?.promoteEE ? [
261
+ {
262
+ intlLabel: { id: "Settings.sso.title", defaultMessage: "Single Sign-On" },
263
+ to: "/settings/purchase-single-sign-on",
264
+ id: "sso",
265
+ lockIcon: true
266
+ }
267
+ ] : [],
268
+ ...!window.strapi.features.isEnabled(window.strapi.features.REVIEW_WORKFLOWS) && window.strapi?.flags?.promoteEE ? [
269
+ {
270
+ intlLabel: {
271
+ id: "Settings.review-workflows.page.title",
272
+ defaultMessage: "Review Workflows"
273
+ },
274
+ to: "/settings/purchase-review-workflows",
275
+ id: "review-workflows",
276
+ lockIcon: true
277
+ }
278
+ ] : []
279
+ ],
280
+ admin: [
281
+ {
282
+ intlLabel: { id: "global.roles", defaultMessage: "Roles" },
283
+ to: "/settings/roles",
284
+ id: "roles"
285
+ },
286
+ {
287
+ intlLabel: { id: "global.users", defaultMessage: "Users" },
288
+ // Init the search params directly
289
+ to: "/settings/users?pageSize=10&page=1&sort=firstname",
290
+ id: "users"
291
+ },
292
+ ...!window.strapi.features.isEnabled(window.strapi.features.AUDIT_LOGS) && window.strapi?.flags?.promoteEE ? [
293
+ {
294
+ intlLabel: { id: "global.auditLogs", defaultMessage: "Audit Logs" },
295
+ to: "/settings/purchase-audit-logs",
296
+ id: "auditLogs",
297
+ lockIcon: true
298
+ }
299
+ ] : []
300
+ ]
301
+ });
237
302
  const [ConfigurationContextProvider, useConfigurationContext] = createContext("ConfigurationContext");
238
303
  const useConfiguration = () => useConfigurationContext("useConfiguration");
239
304
  function isEnterprise() {
240
305
  return window.strapi.isEE;
241
306
  }
242
- function useEnterprise(ceData, eeCallback, {
243
- defaultValue = null,
244
- combine = (ceData2, eeData) => eeData,
245
- enabled = true
246
- } = {}) {
307
+ const useEnterprise = (ceData, eeCallback, opts = {}) => {
308
+ const { defaultValue = null, combine = (_ceData, eeData) => eeData, enabled = true } = opts;
247
309
  const eeCallbackRef = useCallbackRef(eeCallback);
248
310
  const combineCallbackRef = useCallbackRef(combine);
249
311
  const [{ data }, setData] = React.useState({
@@ -252,21 +314,22 @@ function useEnterprise(ceData, eeCallback, {
252
314
  React.useEffect(() => {
253
315
  async function importEE() {
254
316
  const eeData = await eeCallbackRef();
255
- setData({ data: combineCallbackRef(ceData, eeData) });
317
+ const combinedValue = combineCallbackRef(ceData, eeData);
318
+ setData({ data: combinedValue ? combinedValue : eeData });
256
319
  }
257
320
  if (isEnterprise() && enabled) {
258
321
  importEE();
259
322
  }
260
323
  }, [ceData, eeCallbackRef, combineCallbackRef, enabled]);
261
324
  return data;
262
- }
325
+ };
263
326
  const [LocalesContextProvider, useLocalesContext] = createContext("LocalesContext");
264
327
  const useLocales = () => useLocalesContext("useLocales");
265
328
  const LANGUAGE_LOCAL_STORAGE_KEY = "strapi-admin-language";
266
329
  const LanguageProvider = ({ children, localeNames, messages }) => {
267
330
  const [{ locale }, dispatch] = React.useReducer(
268
- reducer$3,
269
- initialState$8,
331
+ reducer$2,
332
+ initialState$7,
270
333
  () => {
271
334
  const languageFromLocaleStorage = window.localStorage.getItem(LANGUAGE_LOCAL_STORAGE_KEY);
272
335
  if (languageFromLocaleStorage && localeNames[languageFromLocaleStorage]) {
@@ -295,11 +358,11 @@ const LanguageProvider = ({ children, localeNames, messages }) => {
295
358
  const appMessages = defaultsDeep(messages[locale], messages.en);
296
359
  return /* @__PURE__ */ jsx(IntlProvider, { locale, defaultLocale: "en", messages: appMessages, textComponent: "span", children: /* @__PURE__ */ jsx(LocalesContextProvider, { changeLocale, localeNames, children }) });
297
360
  };
298
- const initialState$8 = {
361
+ const initialState$7 = {
299
362
  localeNames: { en: "English" },
300
363
  locale: "en"
301
364
  };
302
- const reducer$3 = (state = initialState$8, action) => {
365
+ const reducer$2 = (state = initialState$7, action) => {
303
366
  switch (action.type) {
304
367
  case "CHANGE_LOCALE": {
305
368
  const { locale } = action;
@@ -313,22 +376,14 @@ const reducer$3 = (state = initialState$8, action) => {
313
376
  }
314
377
  }
315
378
  };
316
- const formatAPIErrors = ({ data }) => {
317
- try {
318
- return Object.keys(data).reduce(
319
- (acc, current) => {
320
- const errorMessage = data[current][0];
321
- acc[current] = {
322
- id: errorMessage,
323
- defaultMessage: errorMessage
324
- };
325
- return acc;
326
- },
327
- {}
328
- );
329
- } catch (err) {
330
- return {};
331
- }
379
+ const Img = styled.img`
380
+ height: ${72 / 16}rem;
381
+ `;
382
+ const Logo = () => {
383
+ const {
384
+ logos: { auth: auth2 }
385
+ } = useConfiguration();
386
+ return /* @__PURE__ */ jsx(Img, { src: auth2?.custom ?? auth2.default, "aria-hidden": true, alt: "" });
332
387
  };
333
388
  const Wrapper = styled(Box)`
334
389
  margin: 0 auto;
@@ -374,15 +429,6 @@ const UnauthenticatedLayout = ({ children }) => {
374
429
  /* @__PURE__ */ jsx(Box, { paddingTop: 2, paddingBottom: 11, children })
375
430
  ] });
376
431
  };
377
- const Img = styled.img`
378
- height: ${72 / 16}rem;
379
- `;
380
- const Logo = () => {
381
- const {
382
- logos: { auth: auth2 }
383
- } = useConfiguration();
384
- return /* @__PURE__ */ jsx(Img, { src: auth2?.custom ?? auth2.default, "aria-hidden": true, alt: "" });
385
- };
386
432
  const FieldActionWrapper = styled(FieldAction)`
387
433
  svg {
388
434
  height: 1rem;
@@ -392,16 +438,64 @@ const FieldActionWrapper = styled(FieldAction)`
392
438
  }
393
439
  }
394
440
  `;
395
- const PasswordInput$2 = styled(TextInput)`
396
- ::-ms-reveal {
397
- display: none;
398
- }
399
- `;
400
- const Login = ({ onSubmit, schema, children }) => {
401
- const [passwordShown, setPasswordShown] = useState(false);
441
+ const LOGIN_SCHEMA = yup.object().shape({
442
+ email: yup.string().email(translatedErrors.email).required(translatedErrors.required),
443
+ password: yup.string().required(translatedErrors.required),
444
+ rememberMe: yup.bool().nullable()
445
+ });
446
+ const Login = ({ children }) => {
447
+ const [apiError, setApiError] = React.useState();
448
+ const [passwordShown, setPasswordShown] = React.useState(false);
402
449
  const { formatMessage } = useIntl();
403
- return /* @__PURE__ */ jsxs(Main, { children: [
450
+ const { post } = useFetchClient();
451
+ const { changeLocale } = useLocales();
452
+ const query = useQuery();
453
+ const { push } = useHistory();
454
+ const mutation = useMutation(
455
+ async (body) => {
456
+ const {
457
+ data: { data }
458
+ } = await post("/admin/login", body);
459
+ return { ...data, rememberMe: body.rememberMe };
460
+ },
461
+ {
462
+ onSuccess(data) {
463
+ if (data) {
464
+ const { token, user } = data;
465
+ if (user.preferedLanguage) {
466
+ changeLocale(user.preferedLanguage);
467
+ }
468
+ auth.setToken(token, data.rememberMe);
469
+ auth.setUserInfo(user, data.rememberMe);
470
+ const redirectTo = query.get("redirectTo");
471
+ const redirectUrl = redirectTo ? decodeURIComponent(redirectTo) : "/";
472
+ push(redirectUrl);
473
+ }
474
+ },
475
+ onError(err) {
476
+ const message = err.response?.data?.error?.message ?? "Something went wrong";
477
+ if (camelCase(message).toLowerCase() === "usernotactive") {
478
+ push("/auth/oops");
479
+ return;
480
+ }
481
+ setApiError(message);
482
+ }
483
+ }
484
+ );
485
+ return /* @__PURE__ */ jsx(UnauthenticatedLayout, { children: /* @__PURE__ */ jsxs(Main, { children: [
404
486
  /* @__PURE__ */ jsxs(LayoutContent, { children: [
487
+ /* @__PURE__ */ jsxs(Column, { children: [
488
+ /* @__PURE__ */ jsx(Logo, {}),
489
+ /* @__PURE__ */ jsx(Box, { paddingTop: 6, paddingBottom: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "alpha", as: "h1", children: formatMessage({
490
+ id: "Auth.form.welcome.title",
491
+ defaultMessage: "Welcome!"
492
+ }) }) }),
493
+ /* @__PURE__ */ jsx(Box, { paddingBottom: 7, children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({
494
+ id: "Auth.form.welcome.subtitle",
495
+ defaultMessage: "Log in to your Strapi account"
496
+ }) }) }),
497
+ mutation.isError && apiError ? /* @__PURE__ */ jsx(Typography, { id: "global-form-error", role: "alert", tabIndex: -1, textColor: "danger600", children: apiError }) : null
498
+ ] }),
405
499
  /* @__PURE__ */ jsx(
406
500
  Formik,
407
501
  {
@@ -411,171 +505,141 @@ const Login = ({ onSubmit, schema, children }) => {
411
505
  password: "",
412
506
  rememberMe: false
413
507
  },
414
- onSubmit,
415
- validationSchema: schema,
508
+ onSubmit: (values) => {
509
+ mutation.mutate(values);
510
+ },
511
+ validationSchema: LOGIN_SCHEMA,
416
512
  validateOnChange: false,
417
- children: ({ values, errors, handleChange }) => /* @__PURE__ */ jsxs(Form, { noValidate: true, children: [
418
- /* @__PURE__ */ jsxs(Column, { children: [
419
- /* @__PURE__ */ jsx(Logo, {}),
420
- /* @__PURE__ */ jsx(Box, { paddingTop: 6, paddingBottom: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "alpha", as: "h1", children: formatMessage({
421
- id: "Auth.form.welcome.title",
422
- defaultMessage: "Welcome!"
423
- }) }) }),
424
- /* @__PURE__ */ jsx(Box, { paddingBottom: 7, children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({
425
- id: "Auth.form.welcome.subtitle",
426
- defaultMessage: "Log in to your Strapi account"
427
- }) }) }),
428
- errors.errorMessage && /* @__PURE__ */ jsx(
429
- Typography,
430
- {
431
- id: "global-form-error",
432
- role: "alert",
433
- tabIndex: -1,
434
- textColor: "danger600",
435
- children: errors.errorMessage
436
- }
437
- )
438
- ] }),
439
- /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
440
- /* @__PURE__ */ jsx(
441
- TextInput,
442
- {
443
- error: errors.email ? formatMessage({
444
- id: errors.email,
445
- defaultMessage: "This value is required."
446
- }) : "",
447
- value: values.email,
448
- onChange: handleChange,
449
- label: formatMessage({ id: "Auth.form.email.label", defaultMessage: "Email" }),
450
- placeholder: formatMessage({
451
- id: "Auth.form.email.placeholder",
452
- defaultMessage: "kai@doe.com"
453
- }),
454
- name: "email",
455
- required: true
456
- }
457
- ),
458
- /* @__PURE__ */ jsx(
459
- PasswordInput$2,
460
- {
461
- error: errors.password ? formatMessage({
462
- id: errors.password,
463
- defaultMessage: "This value is required."
464
- }) : "",
465
- onChange: handleChange,
466
- value: values.password,
467
- label: formatMessage({
468
- id: "global.password",
469
- defaultMessage: "Password"
470
- }),
471
- name: "password",
472
- type: passwordShown ? "text" : "password",
473
- endAction: /* @__PURE__ */ jsx(
474
- FieldActionWrapper,
475
- {
476
- onClick: (e) => {
477
- e.stopPropagation();
478
- setPasswordShown((prev) => !prev);
479
- },
480
- label: formatMessage(
481
- passwordShown ? {
482
- id: "Auth.form.password.show-password",
483
- defaultMessage: "Show password"
484
- } : {
485
- id: "Auth.form.password.hide-password",
486
- defaultMessage: "Hide password"
487
- }
488
- ),
489
- children: passwordShown ? /* @__PURE__ */ jsx(Eye, {}) : /* @__PURE__ */ jsx(EyeStriked, {})
490
- }
491
- ),
492
- required: true
493
- }
494
- ),
495
- /* @__PURE__ */ jsx(
496
- Checkbox,
497
- {
498
- onValueChange: (checked) => {
499
- handleChange({ target: { value: checked, name: "rememberMe" } });
500
- },
501
- value: values.rememberMe,
502
- "aria-label": "rememberMe",
503
- name: "rememberMe",
504
- children: formatMessage({
505
- id: "Auth.form.rememberMe.label",
506
- defaultMessage: "Remember me"
507
- })
508
- }
509
- ),
510
- /* @__PURE__ */ jsx(Button, { fullWidth: true, type: "submit", children: formatMessage({ id: "Auth.form.button.login", defaultMessage: "Login" }) })
511
- ] })
512
- ] })
513
+ children: ({ values, errors, handleChange }) => /* @__PURE__ */ jsx(Form, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
514
+ /* @__PURE__ */ jsx(
515
+ TextInput,
516
+ {
517
+ error: errors.email ? formatMessage({
518
+ id: errors.email,
519
+ defaultMessage: "This value is required."
520
+ }) : "",
521
+ value: values.email,
522
+ onChange: handleChange,
523
+ label: formatMessage({ id: "Auth.form.email.label", defaultMessage: "Email" }),
524
+ placeholder: formatMessage({
525
+ id: "Auth.form.email.placeholder",
526
+ defaultMessage: "kai@doe.com"
527
+ }),
528
+ name: "email",
529
+ required: true
530
+ }
531
+ ),
532
+ /* @__PURE__ */ jsx(
533
+ PasswordInput$2,
534
+ {
535
+ error: errors.password ? formatMessage({
536
+ id: errors.password,
537
+ defaultMessage: "This value is required."
538
+ }) : "",
539
+ onChange: handleChange,
540
+ value: values.password,
541
+ label: formatMessage({
542
+ id: "global.password",
543
+ defaultMessage: "Password"
544
+ }),
545
+ name: "password",
546
+ type: passwordShown ? "text" : "password",
547
+ endAction: /* @__PURE__ */ jsx(
548
+ FieldActionWrapper,
549
+ {
550
+ onClick: (e) => {
551
+ e.stopPropagation();
552
+ setPasswordShown((prev) => !prev);
553
+ },
554
+ label: formatMessage(
555
+ passwordShown ? {
556
+ id: "Auth.form.password.show-password",
557
+ defaultMessage: "Show password"
558
+ } : {
559
+ id: "Auth.form.password.hide-password",
560
+ defaultMessage: "Hide password"
561
+ }
562
+ ),
563
+ children: passwordShown ? /* @__PURE__ */ jsx(Eye, {}) : /* @__PURE__ */ jsx(EyeStriked, {})
564
+ }
565
+ ),
566
+ required: true
567
+ }
568
+ ),
569
+ /* @__PURE__ */ jsx(
570
+ Checkbox,
571
+ {
572
+ onValueChange: (checked) => {
573
+ handleChange({ target: { value: checked, name: "rememberMe" } });
574
+ },
575
+ value: values.rememberMe,
576
+ "aria-label": "rememberMe",
577
+ name: "rememberMe",
578
+ children: formatMessage({
579
+ id: "Auth.form.rememberMe.label",
580
+ defaultMessage: "Remember me"
581
+ })
582
+ }
583
+ ),
584
+ /* @__PURE__ */ jsx(Button, { fullWidth: true, type: "submit", children: formatMessage({ id: "Auth.form.button.login", defaultMessage: "Login" }) })
585
+ ] }) })
513
586
  }
514
587
  ),
515
588
  children
516
589
  ] }),
517
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { to: "/auth/forgot-password", children: formatMessage({
590
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { as: NavLink, to: "/auth/forgot-password", children: formatMessage({
518
591
  id: "Auth.link.forgot-password",
519
592
  defaultMessage: "Forgot your password?"
520
593
  }) }) }) })
521
- ] });
594
+ ] }) });
522
595
  };
523
- Login.defaultProps = {
524
- children: null,
525
- onSubmit() {
596
+ const PasswordInput$2 = styled(TextInput)`
597
+ ::-ms-reveal {
598
+ display: none;
526
599
  }
527
- };
528
- Login.propTypes = {
529
- children: PropTypes.node,
530
- onSubmit: PropTypes.func,
531
- schema: PropTypes.shape({
532
- type: PropTypes.string.isRequired
533
- }).isRequired
534
- };
535
- const LoginCE = (loginProps) => {
536
- return /* @__PURE__ */ jsx(UnauthenticatedLayout, { children: /* @__PURE__ */ jsx(Login, { ...loginProps }) });
537
- };
538
- LoginCE.defaultProps = {
539
- onSubmit: (e) => e.preventDefault()
540
- };
541
- LoginCE.propTypes = {
542
- onSubmit: PropTypes.func
543
- };
544
- const ForgotPassword$1 = ({ onSubmit, schema }) => {
600
+ `;
601
+ const ForgotPassword = () => {
602
+ const { push } = useHistory();
603
+ const { post } = useFetchClient();
545
604
  const { formatMessage } = useIntl();
605
+ const { mutate, isError } = useMutation(
606
+ async (body) => {
607
+ await post("/admin/forgot-password", body);
608
+ },
609
+ {
610
+ onSuccess() {
611
+ push("/auth/forgot-password-success");
612
+ }
613
+ }
614
+ );
546
615
  return /* @__PURE__ */ jsx(UnauthenticatedLayout, { children: /* @__PURE__ */ jsxs(Main, { children: [
547
- /* @__PURE__ */ jsx(LayoutContent, { children: /* @__PURE__ */ jsx(
548
- Formik,
549
- {
550
- enableReinitialize: true,
551
- initialValues: {
552
- email: ""
553
- },
554
- onSubmit,
555
- validationSchema: schema,
556
- validateOnChange: false,
557
- children: ({ values, errors, handleChange }) => /* @__PURE__ */ jsxs(Form, { noValidate: true, children: [
558
- /* @__PURE__ */ jsxs(Column, { children: [
559
- /* @__PURE__ */ jsx(Logo, {}),
560
- /* @__PURE__ */ jsx(Box, { paddingTop: 6, paddingBottom: 7, children: /* @__PURE__ */ jsx(Typography, { as: "h1", variant: "alpha", children: formatMessage({
561
- id: "Auth.form.button.password-recovery",
562
- defaultMessage: "Password Recovery"
563
- }) }) }),
564
- errors.errorMessage && /* @__PURE__ */ jsx(
565
- Typography,
566
- {
567
- id: "global-form-error",
568
- role: "alert",
569
- tabIndex: -1,
570
- textColor: "danger600",
571
- children: formatMessage({
572
- id: errors.errorMessage,
573
- defaultMessage: "An error occurred"
574
- })
575
- }
576
- )
577
- ] }),
578
- /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
616
+ /* @__PURE__ */ jsxs(LayoutContent, { children: [
617
+ /* @__PURE__ */ jsxs(Column, { children: [
618
+ /* @__PURE__ */ jsx(Logo, {}),
619
+ /* @__PURE__ */ jsx(Box, { paddingTop: 6, paddingBottom: 7, children: /* @__PURE__ */ jsx(Typography, { as: "h1", variant: "alpha", children: formatMessage({
620
+ id: "Auth.form.button.password-recovery",
621
+ defaultMessage: "Password Recovery"
622
+ }) }) }),
623
+ isError ? /* @__PURE__ */ jsx(Typography, { id: "global-form-error", role: "alert", tabIndex: -1, textColor: "danger600", children: formatMessage({
624
+ id: "notification.error",
625
+ defaultMessage: "An error occurred"
626
+ }) }) : null
627
+ ] }),
628
+ /* @__PURE__ */ jsx(
629
+ Formik,
630
+ {
631
+ enableReinitialize: true,
632
+ initialValues: {
633
+ email: ""
634
+ },
635
+ onSubmit: (values) => {
636
+ mutate(values);
637
+ },
638
+ validationSchema: yup.object().shape({
639
+ email: yup.string().email(translatedErrors.email).required(translatedErrors.required)
640
+ }),
641
+ validateOnChange: false,
642
+ children: ({ values, errors, handleChange }) => /* @__PURE__ */ jsx(Form, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
579
643
  /* @__PURE__ */ jsx(
580
644
  TextInput,
581
645
  {
@@ -598,22 +662,13 @@ const ForgotPassword$1 = ({ onSubmit, schema }) => {
598
662
  id: "Auth.form.button.forgot-password",
599
663
  defaultMessage: "Send Email"
600
664
  }) })
601
- ] })
602
- ] })
603
- }
604
- ) }),
605
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { to: "/auth/login", children: formatMessage({ id: "Auth.link.ready", defaultMessage: "Ready to sign in?" }) }) }) })
665
+ ] }) })
666
+ }
667
+ )
668
+ ] }),
669
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { as: NavLink, to: "/auth/login", children: formatMessage({ id: "Auth.link.ready", defaultMessage: "Ready to sign in?" }) }) }) })
606
670
  ] }) });
607
671
  };
608
- ForgotPassword$1.defaultProps = {
609
- onSubmit: (e) => e.preventDefault()
610
- };
611
- ForgotPassword$1.propTypes = {
612
- onSubmit: PropTypes.func,
613
- schema: PropTypes.shape({
614
- type: PropTypes.string.isRequired
615
- }).isRequired
616
- };
617
672
  const ForgotPasswordSuccess = () => {
618
673
  const { formatMessage } = useIntl();
619
674
  return /* @__PURE__ */ jsx(UnauthenticatedLayout, { children: /* @__PURE__ */ jsxs(Main, { children: [
@@ -632,7 +687,7 @@ const ForgotPasswordSuccess = () => {
632
687
  defaultMessage: "If you do not receive this link, please contact your administrator."
633
688
  }) }) })
634
689
  ] }) }),
635
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { to: "/auth/login", children: formatMessage({ id: "Auth.link.signin", defaultMessage: "Sign in" }) }) }) })
690
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { as: NavLink, to: "/auth/login", children: formatMessage({ id: "Auth.link.signin", defaultMessage: "Sign in" }) }) }) })
636
691
  ] }) });
637
692
  };
638
693
  const Oops = () => {
@@ -652,7 +707,7 @@ const Oops = () => {
652
707
  defaultMessage: "If this is a mistake, please contact your administrator."
653
708
  }) }) })
654
709
  ] }) }),
655
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { to: "/auth/login", children: formatMessage({ id: "Auth.link.signin", defaultMessage: "Sign in" }) }) }) })
710
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { as: NavLink, to: "/auth/login", children: formatMessage({ id: "Auth.link.signin", defaultMessage: "Sign in" }) }) }) })
656
711
  ] }) });
657
712
  };
658
713
  const FieldWrapper = styled(Field)`
@@ -941,25 +996,36 @@ function useNpsSurveySettings() {
941
996
  );
942
997
  return { npsSurveySettings, setNpsSurveySettings };
943
998
  }
944
- const A = styled.a`
945
- color: ${({ theme }) => theme.colors.primary600};
946
- `;
947
- const PasswordInput$1 = styled(TextInput)`
948
- ::-ms-reveal {
949
- display: none;
950
- }
951
- `;
952
- const Register = ({ authType, fieldsToDisable, noSignin, onSubmit, schema }) => {
999
+ const REGISTER_USER_SCHEMA = yup.object().shape({
1000
+ firstname: yup.string().trim().required(translatedErrors.required),
1001
+ lastname: yup.string().nullable(),
1002
+ password: yup.string().min(8, translatedErrors.minLength).matches(/[a-z]/, "components.Input.error.contain.lowercase").matches(/[A-Z]/, "components.Input.error.contain.uppercase").matches(/\d/, "components.Input.error.contain.number").required(translatedErrors.required),
1003
+ confirmPassword: yup.string().oneOf([yup.ref("password"), null], "components.Input.error.password.noMatch").required(translatedErrors.required),
1004
+ registrationToken: yup.string().required(translatedErrors.required)
1005
+ });
1006
+ const REGISTER_ADMIN_SCHEMA = yup.object().shape({
1007
+ firstname: yup.string().trim().required(translatedErrors.required),
1008
+ lastname: yup.string().nullable(),
1009
+ password: yup.string().min(8, translatedErrors.minLength).matches(/[a-z]/, "components.Input.error.contain.lowercase").matches(/[A-Z]/, "components.Input.error.contain.uppercase").matches(/\d/, "components.Input.error.contain.number").required(translatedErrors.required),
1010
+ email: yup.string().email(translatedErrors.email).strict().lowercase(translatedErrors.lowercase).required(translatedErrors.required),
1011
+ confirmPassword: yup.string().oneOf([yup.ref("password"), null], "components.Input.error.password.noMatch").required(translatedErrors.required)
1012
+ });
1013
+ const Register = ({ hasAdmin }) => {
953
1014
  const toggleNotification = useNotification();
954
1015
  const { push } = useHistory();
955
- const [passwordShown, setPasswordShown] = useState(false);
956
- const [confirmPasswordShown, setConfirmPasswordShown] = useState(false);
957
- const [submitCount, setSubmitCount] = useState(0);
1016
+ const [passwordShown, setPasswordShown] = React.useState(false);
1017
+ const [confirmPasswordShown, setConfirmPasswordShown] = React.useState(false);
1018
+ const [submitCount, setSubmitCount] = React.useState(0);
1019
+ const [apiError, setApiError] = React.useState();
958
1020
  const { trackUsage } = useTracking();
959
1021
  const { formatMessage } = useIntl();
1022
+ const { setSkipped } = useGuidedTour();
960
1023
  const query = useQuery();
1024
+ const match = useRouteMatch(
1025
+ "/auth/:authType"
1026
+ );
961
1027
  const { formatAPIError } = useAPIErrorHandler();
962
- const { get: get2 } = useFetchClient();
1028
+ const { get: get2, post } = useFetchClient();
963
1029
  const { setNpsSurveySettings } = useNpsSurveySettings();
964
1030
  const registrationToken = query.get("registrationToken");
965
1031
  const { data: userInfo } = useQuery$1({
@@ -985,28 +1051,97 @@ const Register = ({ authType, fieldsToDisable, noSignin, onSubmit, schema }) =>
985
1051
  push(`/auth/oops?info=${encodeURIComponent(message)}`);
986
1052
  }
987
1053
  });
988
- function normalizeData(data) {
989
- return Object.entries(data).reduce((acc, [key, value]) => {
990
- let normalizedvalue = value;
991
- if (!["password", "confirmPassword"].includes(key) && typeof value === "string") {
992
- normalizedvalue = normalizedvalue.trim();
993
- if (key === "lastname") {
994
- normalizedvalue = normalizedvalue || null;
1054
+ const registerAdminMutation = useMutation(
1055
+ async (body) => {
1056
+ const { news, ...restBody } = body;
1057
+ const { data } = await post("/admin/register-admin", restBody);
1058
+ return { ...data.data, news };
1059
+ },
1060
+ {
1061
+ onSuccess(data) {
1062
+ const { token, user, news } = data;
1063
+ auth.setToken(token, false);
1064
+ auth.setUserInfo(user, false);
1065
+ const { roles } = user;
1066
+ if (roles) {
1067
+ const isUserSuperAdmin = roles.find(({ code }) => code === "strapi-super-admin");
1068
+ if (isUserSuperAdmin) {
1069
+ auth.set(false, "GUIDED_TOUR_SKIPPED", true);
1070
+ setSkipped(false);
1071
+ trackUsage("didLaunchGuidedtour");
1072
+ }
1073
+ }
1074
+ if (news) {
1075
+ setNpsSurveySettings((s) => ({ ...s, enabled: true }));
1076
+ push({
1077
+ pathname: "/usecase",
1078
+ search: `?hasAdmin=${true}`
1079
+ });
1080
+ } else {
1081
+ push("/");
995
1082
  }
1083
+ },
1084
+ onError(err) {
1085
+ trackUsage("didNotCreateFirstAdmin");
1086
+ const error = formatAPIError(err);
1087
+ setApiError(error);
996
1088
  }
997
- acc[key] = normalizedvalue;
998
- return acc;
999
- }, {});
1000
- }
1001
- return /* @__PURE__ */ jsx(UnauthenticatedLayout, { children: /* @__PURE__ */ jsxs(LayoutContent, { children: [
1002
- /* @__PURE__ */ jsx(
1003
- Formik,
1004
- {
1005
- enableReinitialize: true,
1006
- initialValues: {
1007
- firstname: userInfo.firstname || "",
1008
- lastname: userInfo.lastname || "",
1009
- email: userInfo.email || "",
1089
+ }
1090
+ );
1091
+ const registerUserMutation = useMutation(
1092
+ async (body) => {
1093
+ const { news, ...restBody } = body;
1094
+ const { data } = await post("/admin/register", restBody);
1095
+ return { ...data.data, news };
1096
+ },
1097
+ {
1098
+ onSuccess(data) {
1099
+ const { token, user, news } = data;
1100
+ auth.setToken(token, false);
1101
+ auth.setUserInfo(user, false);
1102
+ if (news) {
1103
+ setNpsSurveySettings((s) => ({ ...s, enabled: true }));
1104
+ push({
1105
+ pathname: "/usecase",
1106
+ search: `?hasAdmin=${hasAdmin}`
1107
+ });
1108
+ } else {
1109
+ push("/");
1110
+ }
1111
+ },
1112
+ onError(err) {
1113
+ trackUsage("didNotCreateFirstAdmin");
1114
+ const error = formatAPIError(err);
1115
+ setApiError(error);
1116
+ }
1117
+ }
1118
+ );
1119
+ if (!match || match.params.authType !== "register" && match.params.authType !== "register-admin") {
1120
+ return /* @__PURE__ */ jsx(Redirect, { to: "/" });
1121
+ }
1122
+ const isAdminRegistration = match.params.authType === "register-admin";
1123
+ const schema = isAdminRegistration ? REGISTER_ADMIN_SCHEMA : REGISTER_USER_SCHEMA;
1124
+ return /* @__PURE__ */ jsx(UnauthenticatedLayout, { children: /* @__PURE__ */ jsxs(LayoutContent, { children: [
1125
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 3, children: [
1126
+ /* @__PURE__ */ jsx(Logo, {}),
1127
+ /* @__PURE__ */ jsx(Typography, { as: "h1", variant: "alpha", textAlign: "center", children: formatMessage({
1128
+ id: "Auth.form.welcome.title",
1129
+ defaultMessage: "Welcome to Strapi!"
1130
+ }) }),
1131
+ /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", textAlign: "center", children: formatMessage({
1132
+ id: "Auth.form.register.subtitle",
1133
+ defaultMessage: "Credentials are only used to authenticate in Strapi. All saved data will be stored in your database."
1134
+ }) }),
1135
+ apiError ? /* @__PURE__ */ jsx(Typography, { id: "global-form-error", role: "alert", tabIndex: -1, textColor: "danger600", children: apiError }) : null
1136
+ ] }),
1137
+ /* @__PURE__ */ jsx(
1138
+ Formik,
1139
+ {
1140
+ enableReinitialize: true,
1141
+ initialValues: {
1142
+ firstname: userInfo?.firstname || "",
1143
+ lastname: userInfo?.lastname || "",
1144
+ email: userInfo?.email || "",
1010
1145
  password: "",
1011
1146
  confirmPassword: "",
1012
1147
  registrationToken: registrationToken || void 0,
@@ -1016,265 +1151,291 @@ const Register = ({ authType, fieldsToDisable, noSignin, onSubmit, schema }) =>
1016
1151
  const normalizedData = normalizeData(data);
1017
1152
  try {
1018
1153
  await schema.validate(normalizedData, { abortEarly: false });
1019
- if (submitCount > 0 && authType === "register-admin") {
1154
+ if (submitCount > 0 && isAdminRegistration) {
1020
1155
  trackUsage("didSubmitWithErrorsFirstAdmin", { count: submitCount.toString() });
1021
1156
  }
1022
- if (registrationToken) {
1023
- onSubmit(
1024
- { userInfo: omit(normalizedData, ["registrationToken"]), registrationToken },
1025
- formik
1026
- );
1157
+ if (normalizedData.registrationToken) {
1158
+ registerUserMutation.mutate({
1159
+ userInfo: omit(normalizedData, [
1160
+ "registrationToken",
1161
+ "confirmPassword",
1162
+ "email",
1163
+ "news"
1164
+ ]),
1165
+ registrationToken: normalizedData.registrationToken,
1166
+ news: normalizedData.news
1167
+ });
1027
1168
  } else {
1028
- onSubmit(normalizedData, formik);
1169
+ registerAdminMutation.mutate(
1170
+ omit(normalizedData, ["registrationToken", "confirmPassword"])
1171
+ );
1029
1172
  }
1030
- setNpsSurveySettings({ enabled: data.news });
1031
1173
  } catch (err) {
1032
- const errors = getYupInnerErrors(err);
1174
+ if (err instanceof ValidationError) {
1175
+ const errors = getYupInnerErrors(err);
1176
+ formik.setErrors(errors);
1177
+ }
1033
1178
  setSubmitCount(submitCount + 1);
1034
- formik.setErrors(errors);
1035
1179
  }
1036
1180
  },
1037
1181
  validateOnChange: false,
1038
1182
  children: ({ values, errors, handleChange }) => {
1039
- return /* @__PURE__ */ jsx(Form, { noValidate: true, children: /* @__PURE__ */ jsxs(Main, { children: [
1040
- /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 3, children: [
1041
- /* @__PURE__ */ jsx(Logo, {}),
1042
- /* @__PURE__ */ jsx(Typography, { as: "h1", variant: "alpha", textAlign: "center", children: formatMessage({
1043
- id: "Auth.form.welcome.title",
1044
- defaultMessage: "Welcome to Strapi!"
1045
- }) }),
1046
- /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", textAlign: "center", children: formatMessage({
1047
- id: "Auth.form.register.subtitle",
1048
- defaultMessage: "Credentials are only used to authenticate in Strapi. All saved data will be stored in your database."
1049
- }) })
1050
- ] }),
1051
- /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, marginTop: 7, children: [
1052
- /* @__PURE__ */ jsxs(Grid, { gap: 4, children: [
1053
- /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(
1054
- TextInput,
1055
- {
1056
- name: "firstname",
1057
- required: true,
1058
- value: values.firstname,
1059
- error: errors.firstname ? formatMessage(errors.firstname) : void 0,
1060
- onChange: handleChange,
1061
- label: formatMessage({
1062
- id: "Auth.form.firstname.label",
1063
- defaultMessage: "Firstname"
1064
- })
1065
- }
1066
- ) }),
1067
- /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(
1068
- TextInput,
1069
- {
1070
- name: "lastname",
1071
- value: values.lastname,
1072
- onChange: handleChange,
1073
- label: formatMessage({
1074
- id: "Auth.form.lastname.label",
1075
- defaultMessage: "Lastname"
1076
- })
1077
- }
1078
- ) })
1079
- ] }),
1080
- /* @__PURE__ */ jsx(
1183
+ return /* @__PURE__ */ jsx(Form, { children: /* @__PURE__ */ jsx(Main, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, marginTop: 7, children: [
1184
+ /* @__PURE__ */ jsxs(Grid, { gap: 4, children: [
1185
+ /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(
1081
1186
  TextInput,
1082
1187
  {
1083
- name: "email",
1084
- disabled: fieldsToDisable.includes("email"),
1085
- value: values.email,
1086
- onChange: handleChange,
1087
- error: errors.email ? formatMessage(errors.email) : void 0,
1188
+ name: "firstname",
1088
1189
  required: true,
1089
- label: formatMessage({
1090
- id: "Auth.form.email.label",
1091
- defaultMessage: "Email"
1092
- }),
1093
- type: "email"
1094
- }
1095
- ),
1096
- /* @__PURE__ */ jsx(
1097
- PasswordInput$1,
1098
- {
1099
- name: "password",
1190
+ value: values.firstname,
1191
+ error: errors.firstname ? formatMessage(errors.firstname) : void 0,
1100
1192
  onChange: handleChange,
1101
- value: values.password,
1102
- error: errors.password ? formatMessage(errors.password) : void 0,
1103
- endAction: /* @__PURE__ */ jsx(
1104
- FieldActionWrapper,
1105
- {
1106
- onClick: (e) => {
1107
- e.preventDefault();
1108
- setPasswordShown((prev) => !prev);
1109
- },
1110
- label: formatMessage(
1111
- passwordShown ? {
1112
- id: "Auth.form.password.show-password",
1113
- defaultMessage: "Show password"
1114
- } : {
1115
- id: "Auth.form.password.hide-password",
1116
- defaultMessage: "Hide password"
1117
- }
1118
- ),
1119
- children: passwordShown ? /* @__PURE__ */ jsx(Eye, {}) : /* @__PURE__ */ jsx(EyeStriked, {})
1120
- }
1121
- ),
1122
- hint: formatMessage({
1123
- id: "Auth.form.password.hint",
1124
- defaultMessage: "Must be at least 8 characters, 1 uppercase, 1 lowercase & 1 number"
1125
- }),
1126
- required: true,
1127
1193
  label: formatMessage({
1128
- id: "global.password",
1129
- defaultMessage: "Password"
1130
- }),
1131
- type: passwordShown ? "text" : "password"
1194
+ id: "Auth.form.firstname.label",
1195
+ defaultMessage: "Firstname"
1196
+ })
1132
1197
  }
1133
- ),
1134
- /* @__PURE__ */ jsx(
1135
- PasswordInput$1,
1198
+ ) }),
1199
+ /* @__PURE__ */ jsx(GridItem, { col: 6, children: /* @__PURE__ */ jsx(
1200
+ TextInput,
1136
1201
  {
1137
- name: "confirmPassword",
1202
+ name: "lastname",
1203
+ value: values.lastname,
1138
1204
  onChange: handleChange,
1139
- value: values.confirmPassword,
1140
- error: errors.confirmPassword ? formatMessage(errors.confirmPassword) : void 0,
1141
- endAction: /* @__PURE__ */ jsx(
1142
- FieldActionWrapper,
1143
- {
1144
- onClick: (e) => {
1145
- e.preventDefault();
1146
- setConfirmPasswordShown((prev) => !prev);
1147
- },
1148
- label: formatMessage(
1149
- confirmPasswordShown ? {
1150
- id: "Auth.form.password.show-password",
1151
- defaultMessage: "Show password"
1152
- } : {
1153
- id: "Auth.form.password.hide-password",
1154
- defaultMessage: "Hide password"
1155
- }
1156
- ),
1157
- children: confirmPasswordShown ? /* @__PURE__ */ jsx(Eye, {}) : /* @__PURE__ */ jsx(EyeStriked, {})
1158
- }
1159
- ),
1160
- required: true,
1161
1205
  label: formatMessage({
1162
- id: "Auth.form.confirmPassword.label",
1163
- defaultMessage: "Confirm Password"
1164
- }),
1165
- type: confirmPasswordShown ? "text" : "password"
1206
+ id: "Auth.form.lastname.label",
1207
+ defaultMessage: "Lastname"
1208
+ })
1166
1209
  }
1167
- ),
1168
- /* @__PURE__ */ jsx(
1169
- Checkbox,
1170
- {
1171
- onValueChange: (checked) => {
1172
- handleChange({ target: { value: checked, name: "news" } });
1173
- },
1174
- value: values.news,
1175
- name: "news",
1176
- "aria-label": "news",
1177
- children: formatMessage(
1178
- {
1179
- id: "Auth.form.register.news.label",
1180
- defaultMessage: "Keep me updated about new features & upcoming improvements (by doing this you accept the {terms} and the {policy})."
1210
+ ) })
1211
+ ] }),
1212
+ /* @__PURE__ */ jsx(
1213
+ TextInput,
1214
+ {
1215
+ name: "email",
1216
+ disabled: !isAdminRegistration,
1217
+ value: values.email,
1218
+ onChange: handleChange,
1219
+ error: errors.email ? formatMessage(errors.email) : void 0,
1220
+ required: true,
1221
+ label: formatMessage({
1222
+ id: "Auth.form.email.label",
1223
+ defaultMessage: "Email"
1224
+ }),
1225
+ type: "email"
1226
+ }
1227
+ ),
1228
+ /* @__PURE__ */ jsx(
1229
+ PasswordInput$1,
1230
+ {
1231
+ name: "password",
1232
+ onChange: handleChange,
1233
+ value: values.password,
1234
+ error: errors.password ? formatMessage(errors.password) : void 0,
1235
+ endAction: /* @__PURE__ */ jsx(
1236
+ FieldActionWrapper,
1237
+ {
1238
+ onClick: (e) => {
1239
+ e.preventDefault();
1240
+ setPasswordShown((prev) => !prev);
1181
1241
  },
1182
- {
1183
- terms: /* @__PURE__ */ jsx(A, { target: "_blank", href: "https://strapi.io/terms", rel: "noreferrer", children: formatMessage({
1184
- id: "Auth.privacy-policy-agreement.terms",
1185
- defaultMessage: "terms"
1186
- }) }),
1187
- policy: /* @__PURE__ */ jsx(A, { target: "_blank", href: "https://strapi.io/privacy", rel: "noreferrer", children: formatMessage({
1188
- id: "Auth.privacy-policy-agreement.policy",
1189
- defaultMessage: "policy"
1190
- }) })
1191
- }
1192
- )
1193
- }
1194
- ),
1195
- /* @__PURE__ */ jsx(Button, { fullWidth: true, size: "L", type: "submit", children: formatMessage({
1196
- id: "Auth.form.button.register",
1197
- defaultMessage: "Let's start"
1198
- }) })
1199
- ] })
1200
- ] }) });
1242
+ label: formatMessage(
1243
+ passwordShown ? {
1244
+ id: "Auth.form.password.show-password",
1245
+ defaultMessage: "Show password"
1246
+ } : {
1247
+ id: "Auth.form.password.hide-password",
1248
+ defaultMessage: "Hide password"
1249
+ }
1250
+ ),
1251
+ children: passwordShown ? /* @__PURE__ */ jsx(Eye, {}) : /* @__PURE__ */ jsx(EyeStriked, {})
1252
+ }
1253
+ ),
1254
+ hint: formatMessage({
1255
+ id: "Auth.form.password.hint",
1256
+ defaultMessage: "Must be at least 8 characters, 1 uppercase, 1 lowercase & 1 number"
1257
+ }),
1258
+ required: true,
1259
+ label: formatMessage({
1260
+ id: "global.password",
1261
+ defaultMessage: "Password"
1262
+ }),
1263
+ type: passwordShown ? "text" : "password"
1264
+ }
1265
+ ),
1266
+ /* @__PURE__ */ jsx(
1267
+ PasswordInput$1,
1268
+ {
1269
+ name: "confirmPassword",
1270
+ onChange: handleChange,
1271
+ value: values.confirmPassword,
1272
+ error: errors.confirmPassword ? formatMessage(errors.confirmPassword) : void 0,
1273
+ endAction: /* @__PURE__ */ jsx(
1274
+ FieldActionWrapper,
1275
+ {
1276
+ onClick: (e) => {
1277
+ e.preventDefault();
1278
+ setConfirmPasswordShown((prev) => !prev);
1279
+ },
1280
+ label: formatMessage(
1281
+ confirmPasswordShown ? {
1282
+ id: "Auth.form.password.show-password",
1283
+ defaultMessage: "Show password"
1284
+ } : {
1285
+ id: "Auth.form.password.hide-password",
1286
+ defaultMessage: "Hide password"
1287
+ }
1288
+ ),
1289
+ children: confirmPasswordShown ? /* @__PURE__ */ jsx(Eye, {}) : /* @__PURE__ */ jsx(EyeStriked, {})
1290
+ }
1291
+ ),
1292
+ required: true,
1293
+ label: formatMessage({
1294
+ id: "Auth.form.confirmPassword.label",
1295
+ defaultMessage: "Confirm Password"
1296
+ }),
1297
+ type: confirmPasswordShown ? "text" : "password"
1298
+ }
1299
+ ),
1300
+ /* @__PURE__ */ jsx(
1301
+ Checkbox,
1302
+ {
1303
+ onValueChange: (checked) => {
1304
+ handleChange({ target: { value: checked, name: "news" } });
1305
+ },
1306
+ value: values.news,
1307
+ name: "news",
1308
+ "aria-label": "news",
1309
+ children: formatMessage(
1310
+ {
1311
+ id: "Auth.form.register.news.label",
1312
+ defaultMessage: "Keep me updated about new features & upcoming improvements (by doing this you accept the {terms} and the {policy})."
1313
+ },
1314
+ {
1315
+ terms: /* @__PURE__ */ jsx(A, { target: "_blank", href: "https://strapi.io/terms", rel: "noreferrer", children: formatMessage({
1316
+ id: "Auth.privacy-policy-agreement.terms",
1317
+ defaultMessage: "terms"
1318
+ }) }),
1319
+ policy: /* @__PURE__ */ jsx(A, { target: "_blank", href: "https://strapi.io/privacy", rel: "noreferrer", children: formatMessage({
1320
+ id: "Auth.privacy-policy-agreement.policy",
1321
+ defaultMessage: "policy"
1322
+ }) })
1323
+ }
1324
+ )
1325
+ }
1326
+ ),
1327
+ /* @__PURE__ */ jsx(Button, { fullWidth: true, size: "L", type: "submit", children: formatMessage({
1328
+ id: "Auth.form.button.register",
1329
+ defaultMessage: "Let's start"
1330
+ }) })
1331
+ ] }) }) });
1201
1332
  }
1202
1333
  }
1203
1334
  ),
1204
- !noSignin && /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Link, { label: "Auth.link.signin", to: "/auth/login", children: formatMessage({
1335
+ match?.params.authType === "register" && /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Link, { as: NavLink, to: "/auth/login", children: formatMessage({
1205
1336
  id: "Auth.link.signin.account",
1206
1337
  defaultMessage: "Already have an account?"
1207
1338
  }) }) }) })
1208
1339
  ] }) });
1209
1340
  };
1210
- Register.defaultProps = {
1211
- fieldsToDisable: [],
1212
- noSignin: false,
1213
- onSubmit: (e) => e.preventDefault()
1214
- };
1215
- Register.propTypes = {
1216
- authType: PropTypes.string.isRequired,
1217
- fieldsToDisable: PropTypes.array,
1218
- noSignin: PropTypes.bool,
1219
- onSubmit: PropTypes.func,
1220
- schema: PropTypes.shape({
1221
- validate: PropTypes.func.isRequired,
1222
- type: PropTypes.string.isRequired
1223
- }).isRequired
1224
- };
1225
- const PasswordInput = styled(TextInput)`
1341
+ function normalizeData(data) {
1342
+ return Object.entries(data).reduce(
1343
+ (acc, [key, value]) => {
1344
+ if (!["password", "confirmPassword"].includes(key) && typeof value === "string") {
1345
+ acc[key] = value.trim();
1346
+ if (key === "lastname") {
1347
+ acc[key] = value || void 0;
1348
+ }
1349
+ } else {
1350
+ acc[key] = value;
1351
+ }
1352
+ return acc;
1353
+ },
1354
+ {}
1355
+ );
1356
+ }
1357
+ const A = styled.a`
1358
+ color: ${({ theme }) => theme.colors.primary600};
1359
+ `;
1360
+ const PasswordInput$1 = styled(TextInput)`
1226
1361
  ::-ms-reveal {
1227
1362
  display: none;
1228
1363
  }
1229
1364
  `;
1230
- const ForgotPassword = ({ onSubmit, schema }) => {
1231
- const [passwordShown, setPasswordShown] = useState(false);
1232
- const [confirmPasswordShown, setConfirmPasswordShown] = useState(false);
1365
+ const RESET_PASSWORD_SCHEMA = yup.object().shape({
1366
+ password: yup.string().min(8, translatedErrors.minLength).matches(/[a-z]/, "components.Input.error.contain.lowercase").matches(/[A-Z]/, "components.Input.error.contain.uppercase").matches(/\d/, "components.Input.error.contain.number").required(translatedErrors.required),
1367
+ confirmPassword: yup.string().oneOf([yup.ref("password"), null], "components.Input.error.password.noMatch").required(translatedErrors.required)
1368
+ });
1369
+ const ResetPassword = () => {
1370
+ const [passwordShown, setPasswordShown] = React.useState(false);
1371
+ const [confirmPasswordShown, setConfirmPasswordShown] = React.useState(false);
1233
1372
  const { formatMessage } = useIntl();
1373
+ const { post } = useFetchClient();
1374
+ const { push } = useHistory();
1375
+ const query = useQuery();
1376
+ const { mutate, isError } = useMutation(
1377
+ async (body) => {
1378
+ const {
1379
+ data: { data }
1380
+ } = await post("/admin/reset-password", {
1381
+ ...body,
1382
+ resetPasswordToken: query.get("code")
1383
+ });
1384
+ return data;
1385
+ },
1386
+ {
1387
+ onSuccess(data) {
1388
+ if (data) {
1389
+ const { token, user } = data;
1390
+ auth.setToken(token, false);
1391
+ auth.setUserInfo(user, false);
1392
+ push("/");
1393
+ }
1394
+ }
1395
+ }
1396
+ );
1234
1397
  return /* @__PURE__ */ jsx(UnauthenticatedLayout, { children: /* @__PURE__ */ jsxs(Main, { children: [
1235
- /* @__PURE__ */ jsx(LayoutContent, { children: /* @__PURE__ */ jsx(
1236
- Formik,
1237
- {
1238
- enableReinitialize: true,
1239
- initialValues: {
1240
- password: "",
1241
- confirmPassword: ""
1242
- },
1243
- onSubmit,
1244
- validationSchema: schema,
1245
- validateOnChange: false,
1246
- children: ({ values, errors, handleChange }) => /* @__PURE__ */ jsxs(Form, { noValidate: true, children: [
1247
- /* @__PURE__ */ jsxs(Column, { children: [
1248
- /* @__PURE__ */ jsx(Logo, {}),
1249
- /* @__PURE__ */ jsx(Box, { paddingTop: 6, paddingBottom: 7, children: /* @__PURE__ */ jsx(Typography, { as: "h1", variant: "alpha", children: formatMessage({
1250
- id: "global.reset-password",
1251
- defaultMessage: "Reset password"
1252
- }) }) }),
1253
- errors.errorMessage && /* @__PURE__ */ jsx(
1254
- Typography,
1255
- {
1256
- id: "global-form-error",
1257
- role: "alert",
1258
- tabIndex: -1,
1259
- textColor: "danger600",
1260
- children: formatMessage({
1261
- id: errors.errorMessage,
1262
- defaultMessage: "An error occurred"
1263
- })
1264
- }
1265
- )
1266
- ] }),
1267
- /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
1398
+ /* @__PURE__ */ jsxs(LayoutContent, { children: [
1399
+ /* @__PURE__ */ jsxs(Column, { children: [
1400
+ /* @__PURE__ */ jsx(Logo, {}),
1401
+ /* @__PURE__ */ jsx(Box, { paddingTop: 6, paddingBottom: 7, children: /* @__PURE__ */ jsx(Typography, { as: "h1", variant: "alpha", children: formatMessage({
1402
+ id: "global.reset-password",
1403
+ defaultMessage: "Reset password"
1404
+ }) }) }),
1405
+ isError ? /* @__PURE__ */ jsx(Typography, { id: "global-form-error", role: "alert", tabIndex: -1, textColor: "danger600", children: formatMessage({
1406
+ id: "notification.error",
1407
+ defaultMessage: "An error occurred"
1408
+ }) }) : null
1409
+ ] }),
1410
+ /* @__PURE__ */ jsx(
1411
+ Formik,
1412
+ {
1413
+ enableReinitialize: true,
1414
+ initialValues: {
1415
+ password: "",
1416
+ confirmPassword: ""
1417
+ },
1418
+ onSubmit: (values) => {
1419
+ mutate({ password: values.password });
1420
+ },
1421
+ validationSchema: RESET_PASSWORD_SCHEMA,
1422
+ validateOnChange: false,
1423
+ children: ({ values, errors, handleChange }) => /* @__PURE__ */ jsx(Form, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
1268
1424
  /* @__PURE__ */ jsx(
1269
1425
  PasswordInput,
1270
1426
  {
1271
1427
  name: "password",
1272
1428
  onChange: handleChange,
1273
1429
  value: values.password,
1274
- error: errors.password ? formatMessage({
1275
- id: errors.password,
1276
- defaultMessage: "This field is required."
1277
- }) : void 0,
1430
+ error: errors.password ? formatMessage(
1431
+ {
1432
+ id: errors.password,
1433
+ defaultMessage: "This field is required."
1434
+ },
1435
+ {
1436
+ min: 8
1437
+ }
1438
+ ) : void 0,
1278
1439
  endAction: /* @__PURE__ */ jsx(
1279
1440
  FieldActionWrapper,
1280
1441
  {
@@ -1343,161 +1504,47 @@ const ForgotPassword = ({ onSubmit, schema }) => {
1343
1504
  type: confirmPasswordShown ? "text" : "password"
1344
1505
  }
1345
1506
  ),
1346
- /* @__PURE__ */ jsx(Button, { fullwidth: true, type: "submit", children: formatMessage({
1507
+ /* @__PURE__ */ jsx(Button, { fullWidth: true, type: "submit", children: formatMessage({
1347
1508
  id: "global.change-password",
1348
1509
  defaultMessage: "Change password"
1349
1510
  }) })
1350
- ] })
1351
- ] })
1352
- }
1353
- ) }),
1354
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { to: "/auth/login", children: formatMessage({ id: "Auth.link.ready", defaultMessage: "Ready to sign in?" }) }) }) })
1511
+ ] }) })
1512
+ }
1513
+ )
1514
+ ] }),
1515
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Link, { as: NavLink, to: "/auth/login", children: formatMessage({ id: "Auth.link.ready", defaultMessage: "Ready to sign in?" }) }) }) })
1355
1516
  ] }) });
1356
1517
  };
1357
- ForgotPassword.defaultProps = {
1358
- onSubmit: (e) => e.preventDefault()
1359
- };
1360
- ForgotPassword.propTypes = {
1361
- onSubmit: PropTypes.func,
1362
- schema: PropTypes.shape({
1363
- type: PropTypes.string.isRequired
1364
- }).isRequired
1365
- };
1518
+ const PasswordInput = styled(TextInput)`
1519
+ ::-ms-reveal {
1520
+ display: none;
1521
+ }
1522
+ `;
1366
1523
  const FORMS = {
1367
- "forgot-password": {
1368
- Component: ForgotPassword$1,
1369
- endPoint: "forgot-password",
1370
- fieldsToDisable: [],
1371
- fieldsToOmit: [],
1372
- schema: yup.object().shape({
1373
- email: yup.string().email(translatedErrors.email).required(translatedErrors.required)
1374
- }),
1375
- inputsPrefix: ""
1376
- },
1377
- "forgot-password-success": {
1378
- Component: ForgotPasswordSuccess,
1379
- endPoint: "",
1380
- fieldsToDisable: [],
1381
- fieldsToOmit: [],
1382
- schema: null,
1383
- inputsPrefix: ""
1384
- },
1524
+ "forgot-password": ForgotPassword,
1525
+ "forgot-password-success": ForgotPasswordSuccess,
1385
1526
  // the `Component` attribute is set after all forms and CE/EE components are loaded, but since we
1386
1527
  // are here outside of a React component we can not use the hook directly
1387
- login: {
1388
- endPoint: "login",
1389
- fieldsToDisable: [],
1390
- fieldsToOmit: ["rememberMe"],
1391
- schema: yup.object().shape({
1392
- email: yup.string().email(translatedErrors.email).required(translatedErrors.required),
1393
- password: yup.string().required(translatedErrors.required),
1394
- rememberMe: yup.bool().nullable()
1395
- }),
1396
- inputsPrefix: ""
1397
- },
1398
- oops: {
1399
- Component: Oops,
1400
- endPoint: null,
1401
- fieldsToDisable: [],
1402
- fieldsToOmit: [],
1403
- schema: null,
1404
- inputsPrefix: ""
1405
- },
1406
- register: {
1407
- Component: Register,
1408
- endPoint: "register",
1409
- fieldsToDisable: ["email"],
1410
- fieldsToOmit: ["userInfo.confirmPassword", "userInfo.news", "userInfo.email"],
1411
- schema: yup.object().shape({
1412
- firstname: yup.string().trim().required(translatedErrors.required),
1413
- lastname: yup.string().nullable(),
1414
- password: yup.string().min(8, translatedErrors.minLength).matches(/[a-z]/, "components.Input.error.contain.lowercase").matches(/[A-Z]/, "components.Input.error.contain.uppercase").matches(/\d/, "components.Input.error.contain.number").required(translatedErrors.required),
1415
- confirmPassword: yup.string().oneOf([yup.ref("password"), null], "components.Input.error.password.noMatch").required(translatedErrors.required),
1416
- registrationToken: yup.string().required(translatedErrors.required)
1417
- }),
1418
- inputsPrefix: "userInfo."
1419
- },
1420
- "register-admin": {
1421
- Component: Register,
1422
- endPoint: "register-admin",
1423
- noSignin: true,
1424
- fieldsToDisable: [],
1425
- fieldsToOmit: ["confirmPassword", "news"],
1426
- schema: yup.object().shape({
1427
- firstname: yup.string().trim().required(translatedErrors.required),
1428
- lastname: yup.string().nullable(),
1429
- password: yup.string().min(8, translatedErrors.minLength).matches(/[a-z]/, "components.Input.error.contain.lowercase").matches(/[A-Z]/, "components.Input.error.contain.uppercase").matches(/\d/, "components.Input.error.contain.number").required(translatedErrors.required),
1430
- email: yup.string().email(translatedErrors.email).strict().lowercase(translatedErrors.lowercase).required(translatedErrors.required),
1431
- confirmPassword: yup.string().oneOf([yup.ref("password"), null], "components.Input.error.password.noMatch").required(translatedErrors.required)
1432
- }),
1433
- inputsPrefix: ""
1434
- },
1435
- "reset-password": {
1436
- Component: ForgotPassword,
1437
- endPoint: "reset-password",
1438
- fieldsToDisable: [],
1439
- fieldsToOmit: ["confirmPassword"],
1440
- schema: yup.object().shape({
1441
- password: yup.string().min(8, translatedErrors.minLength).matches(/[a-z]/, "components.Input.error.contain.lowercase").matches(/[A-Z]/, "components.Input.error.contain.uppercase").matches(/\d/, "components.Input.error.contain.number").required(translatedErrors.required),
1442
- confirmPassword: yup.string().oneOf([yup.ref("password"), null], "components.Input.error.password.noMatch").required(translatedErrors.required)
1443
- })
1444
- }
1445
- };
1446
- const init = (initialState2) => {
1447
- return initialState2;
1448
- };
1449
- const initialState$7 = {
1450
- formErrors: {},
1451
- modifiedData: {},
1452
- requestError: null
1453
- };
1454
- const reducer$2 = (state, action) => produce(state, (draftState) => {
1455
- switch (action.type) {
1456
- case "ON_CHANGE": {
1457
- set(draftState.modifiedData, action.keys.split("."), action.value);
1458
- break;
1459
- }
1460
- case "RESET_PROPS": {
1461
- return initialState$7;
1462
- }
1463
- case "SET_DATA": {
1464
- draftState.modifiedData = action.data;
1465
- break;
1466
- }
1467
- case "SET_ERRORS": {
1468
- draftState.formErrors = action.errors;
1469
- break;
1470
- }
1471
- case "SET_REQUEST_ERROR": {
1472
- draftState.requestError = {
1473
- errorMessage: action.errorMessage,
1474
- errorStatus: action.errorStatus
1475
- };
1476
- break;
1477
- }
1478
- default:
1479
- return draftState;
1480
- }
1481
- });
1482
- const AuthPage = ({ hasAdmin, setHasAdmin }) => {
1528
+ login: () => null,
1529
+ oops: Oops,
1530
+ register: Register,
1531
+ "register-admin": Register,
1532
+ "reset-password": ResetPassword,
1533
+ providers: () => null
1534
+ };
1535
+ const AuthPage = ({ hasAdmin }) => {
1483
1536
  const {
1484
- push,
1485
1537
  location: { search }
1486
1538
  } = useHistory();
1487
- const { changeLocale } = useLocales();
1488
- const { setSkipped } = useGuidedTour();
1489
- const { trackUsage } = useTracking();
1490
- const {
1491
- params: { authType }
1492
- } = useRouteMatch("/auth/:authType");
1493
- const query = useQuery();
1494
- const Login2 = useEnterprise(
1495
- LoginCE,
1496
- async () => (await import("./index-305a03f4.mjs")).LoginEE
1539
+ const match = useRouteMatch("/auth/:authType");
1540
+ const authType = match?.params.authType;
1541
+ const Login$1 = useEnterprise(
1542
+ Login,
1543
+ async () => (await import("./Login-02ddabf7.mjs")).LoginEE
1497
1544
  );
1498
1545
  const forms = useEnterprise(
1499
1546
  FORMS,
1500
- async () => (await import("./constants-9de7641c.mjs")).FORMS,
1547
+ async () => (await import("./constants-c0280aed.mjs")).FORMS,
1501
1548
  {
1502
1549
  combine(ceForms, eeForms) {
1503
1550
  return {
@@ -1508,170 +1555,11 @@ const AuthPage = ({ hasAdmin, setHasAdmin }) => {
1508
1555
  defaultValue: FORMS
1509
1556
  }
1510
1557
  );
1511
- const [{ formErrors, modifiedData, requestError }, dispatch] = useReducer(
1512
- reducer$2,
1513
- initialState$7,
1514
- init
1515
- );
1516
- const CancelToken = axios.CancelToken;
1517
- const source = CancelToken.source();
1518
- const { endPoint, fieldsToDisable, fieldsToOmit, inputsPrefix, schema, ...rest } = forms?.[authType] ?? {};
1519
- useEffect(() => {
1520
- return () => {
1521
- source.cancel("Component unmounted");
1522
- };
1523
- }, []);
1524
- const { post } = useFetchClient();
1525
- useEffect(() => {
1526
- dispatch({
1527
- type: "RESET_PROPS"
1528
- });
1529
- }, [authType]);
1530
- const handleChange = ({ target: { name, value } }) => {
1531
- dispatch({
1532
- type: "ON_CHANGE",
1533
- keys: name,
1534
- value
1535
- });
1536
- };
1537
- const handleSubmit = async (e, { setSubmitting, setErrors }) => {
1538
- setSubmitting(true);
1539
- const body = omit(e, fieldsToOmit);
1540
- const requestURL = `/admin/${endPoint}`;
1541
- if (authType === "login") {
1542
- await loginRequest(e, requestURL, { setSubmitting, setErrors });
1543
- }
1544
- if (authType === "register" || authType === "register-admin") {
1545
- await registerRequest(e, requestURL, { setSubmitting, setErrors });
1546
- }
1547
- if (authType === "forgot-password") {
1548
- await forgotPasswordRequest(body, requestURL, { setSubmitting, setErrors });
1549
- }
1550
- if (authType === "reset-password") {
1551
- await resetPasswordRequest(body, requestURL, { setSubmitting, setErrors });
1552
- }
1553
- };
1554
- const forgotPasswordRequest = async (body, requestURL, { setSubmitting, setErrors }) => {
1555
- try {
1556
- await post(requestURL, body, { cancelToken: source.token });
1557
- push("/auth/forgot-password-success");
1558
- } catch (err) {
1559
- console.error(err);
1560
- setErrors({ errorMessage: "notification.error" });
1561
- } finally {
1562
- setSubmitting(false);
1563
- }
1564
- };
1565
- const loginRequest = async (body, requestURL, { setSubmitting, setErrors }) => {
1566
- try {
1567
- const {
1568
- data: {
1569
- data: { token, user }
1570
- }
1571
- } = await post(requestURL, omit(body, fieldsToOmit), { cancelToken: source.token });
1572
- if (user.preferedLanguage) {
1573
- changeLocale(user.preferedLanguage);
1574
- }
1575
- auth.setToken(token, body.rememberMe);
1576
- auth.setUserInfo(user, body.rememberMe);
1577
- redirectToPreviousLocation();
1578
- } catch (err) {
1579
- if (err.response) {
1580
- const errorMessage = get(
1581
- err,
1582
- ["response", "data", "error", "message"],
1583
- "Something went wrong"
1584
- );
1585
- if (camelCase(errorMessage).toLowerCase() === "usernotactive") {
1586
- push("/auth/oops");
1587
- dispatch({
1588
- type: "RESET_PROPS"
1589
- });
1590
- return;
1591
- }
1592
- setErrors({ errorMessage });
1593
- }
1594
- } finally {
1595
- setSubmitting(false);
1596
- }
1597
- };
1598
- const registerRequest = async (body, requestURL, { setSubmitting, setErrors }) => {
1599
- try {
1600
- trackUsage("willCreateFirstAdmin");
1601
- const {
1602
- data: {
1603
- data: { token, user }
1604
- }
1605
- } = await post(requestURL, omit(body, fieldsToOmit), { cancelToken: source.token });
1606
- auth.setToken(token, false);
1607
- auth.setUserInfo(user, false);
1608
- setSubmitting(false);
1609
- setHasAdmin(true);
1610
- const { roles } = user;
1611
- if (roles) {
1612
- const isUserSuperAdmin = roles.find(({ code }) => code === "strapi-super-admin");
1613
- if (isUserSuperAdmin) {
1614
- auth.set(false, "GUIDED_TOUR_SKIPPED", true);
1615
- setSkipped(false);
1616
- trackUsage("didLaunchGuidedtour");
1617
- }
1618
- }
1619
- if (authType === "register" && body.userInfo.news === true || authType === "register-admin" && body.news === true) {
1620
- push({
1621
- pathname: "/usecase",
1622
- search: `?hasAdmin=${hasAdmin}`
1623
- });
1624
- return;
1625
- }
1626
- redirectToPreviousLocation();
1627
- } catch (err) {
1628
- trackUsage("didNotCreateFirstAdmin");
1629
- if (err.response) {
1630
- const { data } = err.response;
1631
- const apiErrors = formatAPIErrors(data);
1632
- setErrors({ apiErrors });
1633
- }
1634
- }
1635
- };
1636
- const resetPasswordRequest = async (body, requestURL, { setErrors, setSubmitting }) => {
1637
- try {
1638
- const {
1639
- data: {
1640
- data: { token, user }
1641
- }
1642
- } = await post(
1643
- requestURL,
1644
- { ...body, resetPasswordToken: query.get("code") },
1645
- { cancelToken: source.token }
1646
- );
1647
- auth.setToken(token, false);
1648
- auth.setUserInfo(user, false);
1649
- push("/");
1650
- } catch (err) {
1651
- if (err.response) {
1652
- const errorMessage = get(err, ["response", "data", "message"], "Something went wrong");
1653
- const errorStatus = get(err, ["response", "data", "statusCode"], 400);
1654
- dispatch({
1655
- type: "SET_REQUEST_ERROR",
1656
- errorMessage,
1657
- errorStatus
1658
- });
1659
- setErrors({ errorMessage });
1660
- }
1661
- } finally {
1662
- setSubmitting(false);
1663
- }
1664
- };
1665
- const redirectToPreviousLocation = () => {
1666
- if (authType === "login") {
1667
- const redirectTo = query.get("redirectTo");
1668
- const redirectUrl = redirectTo ? decodeURIComponent(redirectTo) : "/";
1669
- push(redirectUrl);
1670
- } else {
1671
- push("/");
1672
- }
1673
- };
1674
- if (!forms[authType] || hasAdmin && authType === "register-admin" || auth.getToken()) {
1558
+ if (!authType || !forms) {
1559
+ return /* @__PURE__ */ jsx(Redirect, { to: "/" });
1560
+ }
1561
+ const Component = forms[authType];
1562
+ if (!Component || hasAdmin && authType === "register-admin" || auth.getToken()) {
1675
1563
  return /* @__PURE__ */ jsx(Redirect, { to: "/" });
1676
1564
  }
1677
1565
  if (!hasAdmin && authType !== "register-admin") {
@@ -1687,35 +1575,12 @@ const AuthPage = ({ hasAdmin, setHasAdmin }) => {
1687
1575
  }
1688
1576
  );
1689
1577
  }
1690
- if (Login2) {
1691
- forms.login.Component = Login2;
1692
- }
1693
- if (!Login2) {
1578
+ if (Login$1 && authType === "login") {
1579
+ return /* @__PURE__ */ jsx(Login$1, {});
1580
+ } else if (authType === "login" && !Login$1) {
1694
1581
  return null;
1695
1582
  }
1696
- const { Component } = forms?.[authType] ?? {};
1697
- return /* @__PURE__ */ jsx(
1698
- Component,
1699
- {
1700
- ...rest,
1701
- authType,
1702
- fieldsToDisable,
1703
- formErrors,
1704
- inputsPrefix,
1705
- modifiedData,
1706
- onChange: handleChange,
1707
- onSubmit: handleSubmit,
1708
- requestError,
1709
- schema
1710
- }
1711
- );
1712
- };
1713
- AuthPage.defaultProps = {
1714
- hasAdmin: false
1715
- };
1716
- AuthPage.propTypes = {
1717
- hasAdmin: PropTypes.bool,
1718
- setHasAdmin: PropTypes.func.isRequired
1583
+ return /* @__PURE__ */ jsx(Component, { hasAdmin });
1719
1584
  };
1720
1585
  const NotFoundPage = () => {
1721
1586
  const { formatMessage } = useIntl();
@@ -1910,12 +1775,12 @@ const createRoute = (loadComponent, to, exact = false) => {
1910
1775
  };
1911
1776
  const ROUTES_CE = null;
1912
1777
  const AuthenticatedApp = React.lazy(
1913
- () => import("./AuthenticatedApp-b0ada7e9.mjs").then((n) => n.A).then((mod) => ({ default: mod.AuthenticatedApp }))
1778
+ () => import("./AuthenticatedApp-fd7e406d.mjs").then((n) => n.A).then((mod) => ({ default: mod.AuthenticatedApp }))
1914
1779
  );
1915
1780
  const App = () => {
1916
1781
  const adminPermissions = useEnterprise(
1917
1782
  ADMIN_PERMISSIONS_CE,
1918
- async () => (await import("./constants-921eda17.mjs")).ADMIN_PERMISSIONS_EE,
1783
+ async () => (await import("./constants-6ecddc43.mjs")).ADMIN_PERMISSIONS_EE,
1919
1784
  {
1920
1785
  combine(cePermissions, eePermissions) {
1921
1786
  return merge({}, cePermissions, eePermissions);
@@ -1925,7 +1790,7 @@ const App = () => {
1925
1790
  );
1926
1791
  const routes = useEnterprise(
1927
1792
  ROUTES_CE,
1928
- async () => (await import("./constants-921eda17.mjs")).ROUTES_EE,
1793
+ async () => (await import("./constants-6ecddc43.mjs")).ROUTES_EE,
1929
1794
  {
1930
1795
  defaultValue: []
1931
1796
  }
@@ -2023,7 +1888,6 @@ const App = () => {
2023
1888
  };
2024
1889
  getData();
2025
1890
  }, [toggleNotification, updateProjectSettings]);
2026
- const setHasAdmin = (hasAdmin2) => setState((prev) => ({ ...prev, hasAdmin: hasAdmin2 }));
2027
1891
  const trackingInfo = React.useMemo(
2028
1892
  () => ({
2029
1893
  uuid,
@@ -2043,7 +1907,7 @@ const App = () => {
2043
1907
  Route,
2044
1908
  {
2045
1909
  path: "/auth/:authType",
2046
- render: (routerProps) => /* @__PURE__ */ jsx(AuthPage, { ...routerProps, setHasAdmin, hasAdmin }),
1910
+ render: (routerProps) => /* @__PURE__ */ jsx(AuthPage, { ...routerProps, hasAdmin }),
2047
1911
  exact: true
2048
1912
  }
2049
1913
  ),
@@ -3450,22 +3314,22 @@ const renderAdmin = async (mountNode, { plugins }) => {
3450
3314
  };
3451
3315
  export {
3452
3316
  ACTION_SET_APP_RUNTIME_STATUS as A,
3453
- crudReducer as B,
3317
+ crudInitialState as B,
3454
3318
  Column as C,
3455
- crudInitialState as D,
3456
- RESET_INIT_DATA as E,
3457
- GET_INIT_DATA as F,
3319
+ RESET_INIT_DATA as D,
3320
+ GET_INIT_DATA as E,
3321
+ SET_INIT_DATA as F,
3458
3322
  GET_DATA as G,
3459
3323
  HOOKS as H,
3460
3324
  INIT_FORM as I,
3461
- SET_INIT_DATA as J,
3462
- initialState$3 as K,
3325
+ initialState$3 as J,
3326
+ StrapiLogo as K,
3463
3327
  Login as L,
3464
- StrapiLogo as M,
3328
+ useLocales as M,
3465
3329
  NpsSurvey as N,
3466
3330
  ON_RESET_LIST_HEADERS as O,
3467
- useLocales as P,
3468
- useThemeToggle as Q,
3331
+ useThemeToggle as P,
3332
+ SETTINGS_LINKS_CE as Q,
3469
3333
  RBACProvider as R,
3470
3334
  SET_PERMISSIONS as S,
3471
3335
  getBasename as T,
@@ -3499,6 +3363,6 @@ export {
3499
3363
  ON_CHANGE_LIST_HEADERS as w,
3500
3364
  useInjectionZone as x,
3501
3365
  initialState$1 as y,
3502
- formatAPIErrors as z
3366
+ crudReducer as z
3503
3367
  };
3504
- //# sourceMappingURL=index-34de382e.mjs.map
3368
+ //# sourceMappingURL=index-60a57d31.mjs.map