logo

pleroma-fe

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

registration.vue (11790B)


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