logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

registration.vue (11752B)


  1. <template>
  2. <div class="settings panel panel-default">
  3. <div class="panel-heading">
  4. {{ $t('registration.registration') }}
  5. </div>
  6. <div
  7. v-if="!hasSignUpNotice"
  8. class="panel-body"
  9. >
  10. <form
  11. class="registration-form"
  12. @submit.prevent="submit(user)"
  13. >
  14. <div class="container">
  15. <div class="text-fields">
  16. <div
  17. class="form-group"
  18. :class="{ 'form-group--error': v$.user.username.$error }"
  19. >
  20. <label
  21. class="form--label"
  22. for="sign-up-username"
  23. >{{ $t('login.username') }}</label>
  24. <input
  25. id="sign-up-username"
  26. v-model.trim="v$.user.username.$model"
  27. :disabled="isPending"
  28. class="input form-control"
  29. :aria-required="true"
  30. :placeholder="$t('registration.username_placeholder')"
  31. >
  32. </div>
  33. <div
  34. v-if="v$.user.username.$dirty"
  35. class="form-error"
  36. >
  37. <ul>
  38. <li v-if="!v$.user.username.required">
  39. <span>{{ $t('registration.validations.username_required') }}</span>
  40. </li>
  41. </ul>
  42. </div>
  43. <div
  44. class="form-group"
  45. :class="{ 'form-group--error': v$.user.fullname.$error }"
  46. >
  47. <label
  48. class="form--label"
  49. for="sign-up-fullname"
  50. >{{ $t('registration.fullname') }}</label>
  51. <input
  52. id="sign-up-fullname"
  53. v-model.trim="v$.user.fullname.$model"
  54. :disabled="isPending"
  55. class="input form-control"
  56. :aria-required="true"
  57. :placeholder="$t('registration.fullname_placeholder')"
  58. >
  59. </div>
  60. <div
  61. v-if="v$.user.fullname.$dirty"
  62. class="form-error"
  63. >
  64. <ul>
  65. <li v-if="!v$.user.fullname.required">
  66. <span>{{ $t('registration.validations.fullname_required') }}</span>
  67. </li>
  68. </ul>
  69. </div>
  70. <div
  71. class="form-group"
  72. :class="{ 'form-group--error': v$.user.email.$error }"
  73. >
  74. <label
  75. class="form--label"
  76. for="email"
  77. >{{ accountActivationRequired ? $t('registration.email') : $t('registration.email_optional') }}</label>
  78. <input
  79. id="email"
  80. v-model="v$.user.email.$model"
  81. :disabled="isPending"
  82. class="input form-control"
  83. type="email"
  84. :aria-required="accountActivationRequired"
  85. >
  86. </div>
  87. <div
  88. v-if="v$.user.email.$dirty"
  89. class="form-error"
  90. >
  91. <ul>
  92. <li v-if="!v$.user.email.required">
  93. <span>{{ $t('registration.validations.email_required') }}</span>
  94. </li>
  95. </ul>
  96. </div>
  97. <div class="form-group">
  98. <label
  99. class="form--label"
  100. for="bio"
  101. >{{ $t('registration.bio_optional') }}</label>
  102. <textarea
  103. id="bio"
  104. v-model="user.bio"
  105. :disabled="isPending"
  106. class="input form-control"
  107. :placeholder="bioPlaceholder"
  108. />
  109. </div>
  110. <div
  111. class="form-group"
  112. :class="{ 'form-group--error': v$.user.password.$error }"
  113. >
  114. <label
  115. class="form--label"
  116. for="sign-up-password"
  117. >{{ $t('login.password') }}</label>
  118. <input
  119. id="sign-up-password"
  120. v-model="user.password"
  121. :disabled="isPending"
  122. class="input form-control"
  123. type="password"
  124. :aria-required="true"
  125. >
  126. </div>
  127. <div
  128. v-if="v$.user.password.$dirty"
  129. class="form-error"
  130. >
  131. <ul>
  132. <li v-if="!v$.user.password.required">
  133. <span>{{ $t('registration.validations.password_required') }}</span>
  134. </li>
  135. </ul>
  136. </div>
  137. <div
  138. class="form-group"
  139. :class="{ 'form-group--error': v$.user.confirm.$error }"
  140. >
  141. <label
  142. class="form--label"
  143. for="sign-up-password-confirmation"
  144. >{{ $t('registration.password_confirm') }}</label>
  145. <input
  146. id="sign-up-password-confirmation"
  147. v-model="user.confirm"
  148. :disabled="isPending"
  149. class="input form-control"
  150. type="password"
  151. :aria-required="true"
  152. >
  153. </div>
  154. <div
  155. v-if="v$.user.confirm.$dirty"
  156. class="form-error"
  157. >
  158. <ul>
  159. <li v-if="v$.user.confirm.required.$invalid">
  160. <span>{{ $t('registration.validations.password_confirmation_required') }}</span>
  161. </li>
  162. <li v-if="v$.user.confirm.sameAs.$invalid">
  163. <span>{{ $t('registration.validations.password_confirmation_match') }}</span>
  164. </li>
  165. </ul>
  166. </div>
  167. <div
  168. class="form-group"
  169. :class="{ 'form-group--error': v$.user.birthday.$error }"
  170. >
  171. <label
  172. class="form--label"
  173. for="sign-up-birthday"
  174. >
  175. {{ birthdayRequired ? $t('registration.birthday') : $t('registration.birthday_optional') }}
  176. </label>
  177. <input
  178. id="sign-up-birthday"
  179. v-model="user.birthday"
  180. :disabled="isPending"
  181. class="input form-control"
  182. type="date"
  183. :max="birthdayRequired ? birthdayMinAttr : undefined"
  184. :aria-required="birthdayRequired"
  185. >
  186. </div>
  187. <div
  188. v-if="v$.user.birthday.$dirty"
  189. class="form-error"
  190. >
  191. <ul>
  192. <li v-if="v$.user.birthday.required.$invalid">
  193. <span>{{ $t('registration.validations.birthday_required') }}</span>
  194. </li>
  195. <li v-if="v$.user.birthday.maxValue.$invalid">
  196. <span>{{ $tc('registration.validations.birthday_min_age', { date: birthdayMinFormatted }) }}</span>
  197. </li>
  198. </ul>
  199. </div>
  200. <div
  201. class="form-group"
  202. :class="{ 'form-group--error': v$.user.language.$error }"
  203. >
  204. <interface-language-switcher
  205. for="email-language"
  206. :prompt-text="$t('registration.email_language')"
  207. :language="v$.user.language.$model"
  208. :set-language="val => v$.user.language.$model = val"
  209. @click.stop.prevent
  210. />
  211. </div>
  212. <div
  213. v-if="accountApprovalRequired"
  214. class="form-group"
  215. >
  216. <label
  217. class="form--label"
  218. for="reason"
  219. >{{ $t('registration.reason') }}</label>
  220. <textarea
  221. id="reason"
  222. v-model="user.reason"
  223. :disabled="isPending"
  224. class="input form-control"
  225. :placeholder="reasonPlaceholder"
  226. />
  227. </div>
  228. <div
  229. v-if="captcha.type != 'none'"
  230. id="captcha-group"
  231. class="form-group"
  232. >
  233. <label
  234. class="form--label"
  235. for="captcha-label"
  236. >{{ $t('registration.captcha') }}</label>
  237. <template v-if="['kocaptcha', 'native'].includes(captcha.type)">
  238. <img
  239. :src="captcha.url"
  240. @click="setCaptcha"
  241. >
  242. <sub>{{ $t('registration.new_captcha') }}</sub>
  243. <input
  244. id="captcha-answer"
  245. v-model="captcha.solution"
  246. :disabled="isPending"
  247. class="input form-control"
  248. type="text"
  249. autocomplete="off"
  250. autocorrect="off"
  251. autocapitalize="off"
  252. spellcheck="false"
  253. >
  254. </template>
  255. </div>
  256. <div
  257. v-if="token"
  258. class="form-group"
  259. >
  260. <label for="token">{{ $t('registration.token') }}</label>
  261. <input
  262. id="token"
  263. v-model="token"
  264. disabled="true"
  265. class="input form-control"
  266. type="text"
  267. >
  268. </div>
  269. <div class="form-group">
  270. <button
  271. :disabled="isPending"
  272. type="submit"
  273. class="btn button-default"
  274. >
  275. {{ $t('registration.register') }}
  276. </button>
  277. </div>
  278. </div>
  279. <!-- eslint-disable vue/no-v-html -->
  280. <div
  281. class="terms-of-service"
  282. v-html="termsOfService"
  283. />
  284. <!-- eslint-enable vue/no-v-html -->
  285. </div>
  286. <div
  287. v-if="serverValidationErrors.length"
  288. class="form-group"
  289. >
  290. <div class="alert error">
  291. <span
  292. v-for="error in serverValidationErrors"
  293. :key="error"
  294. >{{ error }}</span>
  295. </div>
  296. </div>
  297. </form>
  298. </div>
  299. <div v-else>
  300. <p class="registration-notice">
  301. {{ signUpNotice.message }}
  302. </p>
  303. </div>
  304. </div>
  305. </template>
  306. <script src="./registration.js"></script>
  307. <style lang="scss">
  308. .registration-form {
  309. display: flex;
  310. flex-direction: column;
  311. margin: 0.6em;
  312. .container {
  313. display: flex;
  314. flex-direction: row;
  315. > * {
  316. min-width: 0;
  317. }
  318. }
  319. .terms-of-service {
  320. flex: 0 1 50%;
  321. margin: 0.8em;
  322. }
  323. .text-fields {
  324. margin-top: 0.6em;
  325. flex: 1 0;
  326. display: flex;
  327. flex-direction: column;
  328. }
  329. textarea {
  330. min-height: 100px;
  331. resize: vertical;
  332. }
  333. .form-group {
  334. display: flex;
  335. flex-direction: column;
  336. padding: 0.3em 0;
  337. line-height: 2;
  338. margin-bottom: 1em;
  339. }
  340. .form-group--error {
  341. animation-name: shakeError;
  342. animation-duration: 0.6s;
  343. animation-timing-function: ease-in-out;
  344. }
  345. .form-group--error .form--label {
  346. color: var(--cRed);
  347. }
  348. .form-error {
  349. margin-top: -0.7em;
  350. text-align: left;
  351. span {
  352. font-size: 0.85em;
  353. }
  354. }
  355. .form-error ul {
  356. list-style: none;
  357. padding: 0 0 0 5px;
  358. margin-top: 0;
  359. li::before {
  360. content: "• ";
  361. }
  362. }
  363. form textarea {
  364. line-height: 16px;
  365. resize: vertical;
  366. }
  367. .captcha {
  368. max-width: 350px;
  369. margin-bottom: 0.4em;
  370. }
  371. .btn {
  372. margin-top: 0.6em;
  373. height: 2em;
  374. }
  375. .error {
  376. text-align: center;
  377. }
  378. }
  379. .registration-notice {
  380. margin: 0.6em;
  381. }
  382. @media all and (max-width: 800px) {
  383. .registration-form .container {
  384. flex-direction: column-reverse;
  385. }
  386. }
  387. </style>