Page MenuHomePhorge

No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js
index 1d8109e44c..dab06e1ee4 100644
--- a/src/components/registration/registration.js
+++ b/src/components/registration/registration.js
@@ -1,77 +1,80 @@
import { validationMixin } from 'vuelidate'
import { required, requiredIf, sameAs } from 'vuelidate/lib/validators'
import { mapActions, mapState } from 'vuex'
const registration = {
mixins: [validationMixin],
data: () => ({
user: {
email: '',
fullname: '',
username: '',
password: '',
confirm: ''
},
captcha: {}
}),
- validations: {
- user: {
- email: requiredIf('accountActivationRequired'),
- username: { required },
- fullname: { required },
- password: { required },
- confirm: {
- required,
- sameAsPassword: sameAs('password')
+ validations () {
+ return {
+ user: {
+ email: { required: requiredIf(() => this.accountActivationRequired) },
+ username: { required },
+ fullname: { required },
+ password: { required },
+ confirm: {
+ required,
+ sameAsPassword: sameAs('password')
+ }
}
}
},
created () {
if ((!this.registrationOpen && !this.token) || this.signedIn) {
this.$router.push({ name: 'root' })
}
this.setCaptcha()
},
computed: {
token () { return this.$route.params.token },
bioPlaceholder () {
return this.$t('registration.bio_placeholder').replace(/\s*\n\s*/g, ' \n')
},
...mapState({
registrationOpen: (state) => state.instance.registrationOpen,
signedIn: (state) => !!state.users.currentUser,
isPending: (state) => state.users.signUpPending,
serverValidationErrors: (state) => state.users.signUpErrors,
- termsOfService: (state) => state.instance.tos
+ termsOfService: (state) => state.instance.tos,
+ accountActivationRequired: (state) => state.instance.accountActivationRequired
})
},
methods: {
...mapActions(['signUp', 'getCaptcha']),
async submit () {
this.user.nickname = this.user.username
this.user.token = this.token
this.user.captcha_solution = this.captcha.solution
this.user.captcha_token = this.captcha.token
this.user.captcha_answer_data = this.captcha.answer_data
this.$v.$touch()
if (!this.$v.$invalid) {
try {
await this.signUp(this.user)
this.$router.push({ name: 'friends' })
} catch (error) {
console.warn('Registration failed: ', error)
this.setCaptcha()
}
}
},
setCaptcha () {
this.getCaptcha().then(cpt => { this.captcha = cpt })
}
}
}
export default registration

File Metadata

Mime Type
text/x-diff
Expires
Sat, Aug 29, 7:42 AM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1736863
Default Alt Text
(2 KB)

Event Timeline