Registrazione - fase 1

This commit is contained in:
paolo
2018-10-15 02:50:06 +02:00
parent 01d5f3cec1
commit a6eb2d2aaa
4 changed files with 42 additions and 27 deletions

View File

@@ -104,6 +104,9 @@
import {mapGetters, mapActions} from 'vuex'
import * as types from '../../../store/mutation-types'
import { Errori_MongoDb } from '../../../store/modules/user'
export default {
data() {
return {
@@ -125,9 +128,19 @@
'getEmail',
'getDateOfBirth',
]),
...mapGetters("user", [
'getUserServer',
'getServerCode',
]),
user() {
//return this.getUserServer();
},
env() {
return env
}
},
userIsAuthenticated() {
return this.getUsername() !== null;
},
},
validations: {
form: {
@@ -141,6 +154,13 @@
}
},
watch: {
getscode(code) {
if (code === Errori_MongoDb.DUPLICATE_EMAIL_ID) {
this.$q.notify(this.$t('reg.err.duplicate_email'));
}
}
},
methods: {
...mapActions("user", {
signup: types.USER_SIGNUP,
@@ -151,6 +171,7 @@
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.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 '';
},
submit() {
@@ -166,16 +187,20 @@
return
}
const formData = {
email: this.email,
username: this.username,
password: this.password,
dateOfBirth: this.dateOfBirth,
confirmPassword: this.confirmPassword,
terms: this.terms,
};
console.log(formData);
this.signup(formData);
var mythis = this;
console.log(this.form);
this.signup(this.form)
.then((riscode) => {
//console.log("RIS = " + riscode);
if (riscode === Errori_MongoDb.DUPLICATE_EMAIL_ID) {
this.$q.notify(this.$t('reg.err.duplicate_email'));
} else {
this.$router.push('/');
}
}).catch(error => {
console.log("ERROR = " + error);
});
// ...
}

View File

@@ -19,7 +19,8 @@ const messages = {
atleast: 'dev\'essere lungo almeno di',
notmore: 'non dev\'essere lungo più di',
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',
notmore: 'must not be more than',
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',
}
},
},

View File

@@ -8,6 +8,7 @@ import types from './mutation-types'
Vue.use(Vuex);
const debug = process.env.NODE_ENV !== 'production';
Vue.filter('time', timestamp => {

View File

@@ -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);
}();