|
|
|
@ -3,6 +3,7 @@ import { required, requiredIf, sameAs } from '@vuelidate/validators'
|
|
|
|
|
import { mapActions, mapState } from 'vuex'
|
|
|
|
|
import InterfaceLanguageSwitcher from '../interface_language_switcher/interface_language_switcher.vue'
|
|
|
|
|
import localeService from '../../services/locale/locale.service.js'
|
|
|
|
|
import { DAY } from 'src/services/date_utils/date_utils.js'
|
|
|
|
|
|
|
|
|
|
const registration = {
|
|
|
|
|
setup () { return { v$: useVuelidate() } },
|
|
|
|
@ -13,6 +14,7 @@ const registration = {
|
|
|
|
|
username: '',
|
|
|
|
|
password: '',
|
|
|
|
|
confirm: '',
|
|
|
|
|
birthday: '',
|
|
|
|
|
reason: '',
|
|
|
|
|
language: ''
|
|
|
|
|
},
|
|
|
|
@ -32,6 +34,12 @@ const registration = {
|
|
|
|
|
required,
|
|
|
|
|
sameAs: sameAs(this.user.password)
|
|
|
|
|
},
|
|
|
|
|
birthday: {
|
|
|
|
|
required: requiredIf(() => this.birthdayRequired),
|
|
|
|
|
maxValue: value => {
|
|
|
|
|
return !this.birthdayRequired || new Date(value).getTime() <= this.birthdayMin.getTime()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
reason: { required: requiredIf(() => this.accountApprovalRequired) },
|
|
|
|
|
language: {}
|
|
|
|
|
}
|
|
|
|
@ -52,6 +60,24 @@ const registration = {
|
|
|
|
|
reasonPlaceholder () {
|
|
|
|
|
return this.replaceNewlines(this.$t('registration.reason_placeholder'))
|
|
|
|
|
},
|
|
|
|
|
birthdayMin () {
|
|
|
|
|
const minAge = this.birthdayMinAge
|
|
|
|
|
const today = new Date()
|
|
|
|
|
today.setUTCMilliseconds(0)
|
|
|
|
|
today.setUTCSeconds(0)
|
|
|
|
|
today.setUTCMinutes(0)
|
|
|
|
|
today.setUTCHours(0)
|
|
|
|
|
const minDate = new Date()
|
|
|
|
|
minDate.setTime(today.getTime() - minAge * DAY)
|
|
|
|
|
return minDate
|
|
|
|
|
},
|
|
|
|
|
birthdayMinAttr () {
|
|
|
|
|
return this.birthdayMin.toJSON().replace(/T.+$/, '')
|
|
|
|
|
},
|
|
|
|
|
birthdayMinFormatted () {
|
|
|
|
|
const browserLocale = localeService.internalToBrowserLocale(this.$i18n.locale)
|
|
|
|
|
return this.user.birthday && new Date(Date.parse(this.birthdayMin)).toLocaleDateString(browserLocale, { timeZone: 'UTC', day: 'numeric', month: 'long', year: 'numeric' })
|
|
|
|
|
},
|
|
|
|
|
...mapState({
|
|
|
|
|
registrationOpen: (state) => state.instance.registrationOpen,
|
|
|
|
|
signedIn: (state) => !!state.users.currentUser,
|
|
|
|
@ -59,7 +85,9 @@ const registration = {
|
|
|
|
|
serverValidationErrors: (state) => state.users.signUpErrors,
|
|
|
|
|
termsOfService: (state) => state.instance.tos,
|
|
|
|
|
accountActivationRequired: (state) => state.instance.accountActivationRequired,
|
|
|
|
|
accountApprovalRequired: (state) => state.instance.accountApprovalRequired
|
|
|
|
|
accountApprovalRequired: (state) => state.instance.accountApprovalRequired,
|
|
|
|
|
birthdayRequired: (state) => state.instance.birthdayRequired,
|
|
|
|
|
birthdayMinAge: (state) => state.instance.birthdayMinAge
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|