Registrazione - fase 1
This commit is contained in:
@@ -104,6 +104,9 @@
|
|||||||
import {mapGetters, mapActions} from 'vuex'
|
import {mapGetters, mapActions} from 'vuex'
|
||||||
import * as types from '../../../store/mutation-types'
|
import * as types from '../../../store/mutation-types'
|
||||||
|
|
||||||
|
import { Errori_MongoDb } from '../../../store/modules/user'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -125,9 +128,19 @@
|
|||||||
'getEmail',
|
'getEmail',
|
||||||
'getDateOfBirth',
|
'getDateOfBirth',
|
||||||
]),
|
]),
|
||||||
|
...mapGetters("user", [
|
||||||
|
'getUserServer',
|
||||||
|
'getServerCode',
|
||||||
|
]),
|
||||||
|
user() {
|
||||||
|
//return this.getUserServer();
|
||||||
|
},
|
||||||
env() {
|
env() {
|
||||||
return env
|
return env
|
||||||
}
|
},
|
||||||
|
userIsAuthenticated() {
|
||||||
|
return this.getUsername() !== null;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
validations: {
|
validations: {
|
||||||
form: {
|
form: {
|
||||||
@@ -137,10 +150,17 @@
|
|||||||
confirmpassword: {
|
confirmpassword: {
|
||||||
sameAsPassword: sameAs('password')
|
sameAsPassword: sameAs('password')
|
||||||
},
|
},
|
||||||
terms: { required },
|
terms: {required},
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
getscode(code) {
|
||||||
|
if (code === Errori_MongoDb.DUPLICATE_EMAIL_ID) {
|
||||||
|
this.$q.notify(this.$t('reg.err.duplicate_email'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions("user", {
|
...mapActions("user", {
|
||||||
signup: types.USER_SIGNUP,
|
signup: types.USER_SIGNUP,
|
||||||
@@ -151,6 +171,7 @@
|
|||||||
if (!item.required) return this.$t('reg.err.required');
|
if (!item.required) return this.$t('reg.err.required');
|
||||||
if (!item.minLength) return this.$t('reg.err.atleast') + ` ${item.$params.minLength.min} ` + this.$t('reg.err.char');
|
if (!item.minLength) return this.$t('reg.err.atleast') + ` ${item.$params.minLength.min} ` + this.$t('reg.err.char');
|
||||||
if (!item.maxLength) return this.$t('reg.err.notmore') + ` ${item.$params.maxLength.max} ` + this.$t('reg.err.char');
|
if (!item.maxLength) return this.$t('reg.err.notmore') + ` ${item.$params.maxLength.max} ` + this.$t('reg.err.char');
|
||||||
|
if (item.duplicated) return this.$t('reg.err.duplicate_email');
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
@@ -166,16 +187,20 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const formData = {
|
var mythis = this;
|
||||||
email: this.email,
|
|
||||||
username: this.username,
|
console.log(this.form);
|
||||||
password: this.password,
|
this.signup(this.form)
|
||||||
dateOfBirth: this.dateOfBirth,
|
.then((riscode) => {
|
||||||
confirmPassword: this.confirmPassword,
|
//console.log("RIS = " + riscode);
|
||||||
terms: this.terms,
|
if (riscode === Errori_MongoDb.DUPLICATE_EMAIL_ID) {
|
||||||
};
|
this.$q.notify(this.$t('reg.err.duplicate_email'));
|
||||||
console.log(formData);
|
} else {
|
||||||
this.signup(formData);
|
this.$router.push('/');
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
console.log("ERROR = " + error);
|
||||||
|
});
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ const messages = {
|
|||||||
atleast: 'dev\'essere lungo almeno di',
|
atleast: 'dev\'essere lungo almeno di',
|
||||||
notmore: 'non dev\'essere lungo più di',
|
notmore: 'non dev\'essere lungo più di',
|
||||||
char: 'caratteri',
|
char: 'caratteri',
|
||||||
terms: 'Devi accettare le condizioni, per continuare.'
|
terms: 'Devi accettare le condizioni, per continuare.',
|
||||||
|
duplicate_email: 'l\'Email è già stata registrata'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -43,7 +44,8 @@ const messages = {
|
|||||||
atleast: 'must be at least',
|
atleast: 'must be at least',
|
||||||
notmore: 'must not be more than',
|
notmore: 'must not be more than',
|
||||||
char: 'characters long',
|
char: 'characters long',
|
||||||
terms: 'You need to agree with the terms & conditions.'
|
terms: 'You need to agree with the terms & conditions.',
|
||||||
|
duplicate_email: 'Email was already registered',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import types from './mutation-types'
|
|||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
Vue.filter('time', timestamp => {
|
Vue.filter('time', timestamp => {
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
var sendRequest = function (url, method, body)
|
|
||||||
{
|
|
||||||
const options = {
|
|
||||||
method: method,
|
|
||||||
mode: 'no-cors',
|
|
||||||
headers: new Headers({'content-type': 'application/json'}),
|
|
||||||
mode: 'no-cors'
|
|
||||||
};
|
|
||||||
|
|
||||||
options.body = JSON.stringify(body);
|
|
||||||
|
|
||||||
return fetch(url, options);
|
|
||||||
}();
|
|
||||||
|
|||||||
Reference in New Issue
Block a user