diff --git a/.env b/.env index 17cb3be..9cd56f0 100644 --- a/.env +++ b/.env @@ -1,16 +1,18 @@ ## SVILUPPO !!! -VUE_APP_URL = "prova SVILUPPO!" -PROVA_PAOLO = "PROVA SVILUPPO" +APP_ID=1 +VUE_APP_URL="prova SVILUPPO!" +PROVA_PAOLO="PROVA SVILUPPO" +LANG_DEFAULT=it -MONGODB_HOST = 'http://localhost:3000' +MONGODB_HOST='http://localhost:3000' -PAO_APP_ID = 'KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF' -MASTER_KEY = 'KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T' +PAO_APP_ID='KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF' +MASTER_KEY='KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T' -LOGO_REG = quasar-logo-full.svg +LOGO_REG=quasar-logo-full.svg -TEST_EMAIL=paolo@prova.com -TEST_USERNAME = paoloar77 -TEST_PASSWORD = mypassword +TEST_EMAIL=paolo.arena77@gmail.com +TEST_USERNAME=paoloar77 +TEST_PASSWORD=mypassword diff --git a/.env.production b/.env.production index 0a84f4e..d20b0a1 100644 --- a/.env.production +++ b/.env.production @@ -1,13 +1,13 @@ -VUE_APP_URL = "PROVA ENV! FUNZIONA" -PROVA_PAOLO = "PROVA ENV FUNZIONA!" +VUE_APP_URL= "PROVA ENV! FUNZIONA" +PROVA_PAOLO= "PROVA ENV FUNZIONA!" -PAO_APP_ID = '' -MASTER_KEY = '' +PAO_APP_ID='' +MASTER_KEY='' -MONGODB_HOST = 'http://localhost:3000' +MONGODB_HOST='http://localhost:3000' -LOGO_REG = 'quasar-logo-full.svg' +LOGO_REG=quasar-logo-full.svg TEST_EMAIL= -TEST_USERNAME = -TEST_PASSWORD = +TEST_USERNAME= +TEST_PASSWORD= diff --git a/config/envparser.js b/config/envparser.js new file mode 100644 index 0000000..d67efa2 --- /dev/null +++ b/config/envparser.js @@ -0,0 +1,12 @@ +const DotEnv = require('dotenv') +const parsedEnv = DotEnv.config().parsed + +module.exports = function () { + // Let's stringify our variables + for (key in parsedEnv) { + if (typeof parsedEnv[key] === 'string') { + parsedEnv[key] = JSON.stringify(parsedEnv[key]) + } + } + return parsedEnv +} diff --git a/config/helpers/env.js b/config/helpers/env.js new file mode 100644 index 0000000..f17d2e4 --- /dev/null +++ b/config/helpers/env.js @@ -0,0 +1,3 @@ +module.exports = function (key, fallback) { + return process.env[key] || fallback +} diff --git a/quasar.conf.js b/quasar.conf.js index 4e2784e..ebb2af3 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -46,7 +46,7 @@ module.exports = function (ctx) { // https: true, port: 8080, host: 'localhost', - open: true // opens browser window automatically + open: false // opens browser window automatically }, framework: { components: [ @@ -81,6 +81,7 @@ module.exports = function (ctx) { 'QChip', 'QCollapsible', 'QCheckbox', + 'QAlert', ], directives: [ diff --git a/src/cfg.js b/src/cfg.js index 99ddb56..ac86570 100644 --- a/src/cfg.js +++ b/src/cfg.js @@ -5,7 +5,7 @@ Vue.use(Vuex); export const cfg = new Vue({ state:{ - lang: 'it' + lang: 'en' }, data: { cost: { diff --git a/src/components/views/login/signup.vue b/src/components/views/login/signup.vue index 388ed5c..ab68528 100644 --- a/src/components/views/login/signup.vue +++ b/src/components/views/login/signup.vue @@ -105,7 +105,6 @@ import * as types from '../../../store/mutation-types' import {Errori_MongoDb} from '../../../store/modules/user' - import axios from 'axios'; @@ -136,9 +135,6 @@ 'getUserServer', 'getServerCode', ]), - user() { - //return this.getUserServer(); - }, env() { return env }, @@ -239,8 +235,6 @@ return } - var mythis = this; - console.log(this.form); this.signup(this.form) .then((riscode) => { diff --git a/src/components/views/login/vreg.vue b/src/components/views/login/vreg.vue new file mode 100644 index 0000000..8825a3b --- /dev/null +++ b/src/components/views/login/vreg.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/src/i18n.js b/src/i18n.js index 77b1bc0..b9c8983 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -13,6 +13,7 @@ const messages = { repeatPassword: 'Ripeti password', terms: "Accetti i termini e le condizioni?", submit: "Registrati", + title_verif_reg: "Verifica Registrazione", err: { required: 'รจ richiesto', email: 'dev\'essere una email valida', @@ -41,6 +42,7 @@ const messages = { repeatPassword: 'Repeat password', terms: "Do you agree with the terms & conditions?", submit: "Submit", + title_verif_reg: "Verify Registration", err: { required: 'is required', email: 'must be a valid email', diff --git a/src/plugins/axios.js b/src/plugins/axios.js new file mode 100644 index 0000000..11b8239 --- /dev/null +++ b/src/plugins/axios.js @@ -0,0 +1,5 @@ +import axios from 'axios' + +export default ({ Vue }) => { + Vue.prototype.$axios = axios +} diff --git a/src/plugins/i18n.js b/src/plugins/i18n.js index c25d086..144a2d6 100644 --- a/src/plugins/i18n.js +++ b/src/plugins/i18n.js @@ -4,14 +4,14 @@ import messages from 'src/i18n'; export default ({ app, store, Vue }) => { Vue.use(VueI18n); - Vue.config.lang = 'it'; + Vue.config.lang = process.env.LANG_DEFAULT; console.log("PLUGINS INIT...."); // Set i18n instance on app app.i18n = new VueI18n({ - locale: 'it', - fallbackLocale: 'it', + locale: process.env.LANG_DEFAULT, + fallbackLocale: process.env.LANG_DEFAULT, messages }) } diff --git a/src/router/routes.js b/src/router/routes.js index 0982a92..bfc55c7 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -11,6 +11,7 @@ const routes = [ { path: '/', component: () => import('pages/Index.vue') }, { path: '/signup', component: load('views/login/signup'), meta: { name: 'Registration' } }, { path: '/login', component: load('views/login/login'), meta: { name: 'Login' } }, + { path: '/vreg', component: load('views/login/vreg'), meta: { name: 'Verify Reg' } }, ]; diff --git a/src/store/modules/serv_constants.js b/src/store/modules/serv_constants.js new file mode 100644 index 0000000..ad9b3ed --- /dev/null +++ b/src/store/modules/serv_constants.js @@ -0,0 +1,4 @@ +export const serv_constants = { + RIS_CODE_EMAIL_ALREADY_VERIFIED: -20, + RIS_CODE_EMAIL_VERIFIED: 1, +}; diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 1f28be4..063b81a 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -6,6 +6,13 @@ Vue.use(Vuex); import * as types from '../mutation-types' //import tools from '../../../tools/tools' +function getlang(){ + if (state.user.lang !== "") + return state.user.lang; + else + return process.env.LANG_DEFAULT +} + export const Errori_MongoDb = { CALLING: 10, OK: 20, @@ -19,24 +26,29 @@ export const state = { _id: '', email: '', username: null, + idapp: process.env.APP_ID, password: '', + lang: '', ripetipassword: '', dateofbirth: '', tokens: [{ access: '', token: '' - }] + }], + + verified_email: false, }, userServer: null, servercode: 0, }; function sendRequest(url, method, mydata) { + console.log("LANG " + getlang()); const options = { method: method, //mode: 'no-cors', - headers: new Headers({'content-type': 'application/json', 'x-auth': ''}), + headers: new Headers({'content-type': 'application/json', 'x-auth': '', 'accept-language': getlang()}), cache: "no-cache", body: JSON.stringify(mydata), }; @@ -55,6 +67,7 @@ export const getters = { getDateOfBirth: state => state.user.dateofbirth, getUserServer: state => state.user.userServer, getServerCode: state => state.servercode, + getLang: state => state.user.lang, }; @@ -71,6 +84,9 @@ export const mutations = { [types.USER_EMAIL]: (state, payload) => { state.user.email = payload; }, + [types.USER_LANG]: (state, payload) => { + state.user.lang = payload; + }, [types.USER_DATEOFBIRTH]: (state, payload) => { state.user.dateOfBirth = payload; }, @@ -104,19 +120,63 @@ export const actions = { [types.USER_EMAIL]: ({commit}, payload) => { commit(types.USER_EMAIL, payload) }, + [types.USER_LANG]: ({commit}, payload) => { + commit(types.USER_LANG, payload) + }, [types.USER_DATEOFBIRTH]: ({commit}, payload) => { commit(types.USER_DATEOFBIRTH, payload) }, + [types.USER_VREG]: ({commit}, paramquery) => { + var call = process.env.MONGODB_HOST + '/vreg'; + console.log("CALL " + call); + + let params = { + keyappid: process.env.PAO_APP_ID, + idapp: process.env.APP_ID, + idlink: paramquery.idlink, + }; + console.log(params); + + commit('setServerCode', Errori_MongoDb.CALLING); + + var myres; + + return sendRequest(call, "POST", params) + .then((res) => { + //console.log("RITORNO 1 "); + console.log(res); + //console.log(res.status); + myres = res; + if (myres.status === 200) { + return myres.json(); + } + commit('setServerCode', Errori_MongoDb.ERR_GENERICO); + return {code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore: ' + myres.status}; + + }) + .then((body) => { + //console.log("RITORNO 2 "); + //commit('setServerCode', myres); + return {code: body.code, msg: body.msg}; + }).catch((err) => { + console.log("ERROR: " + err); + commit('setServerCode', Errori_MongoDb.ERR_GENERICO); + return {code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore'}; + }); + }, + [types.USER_SIGNUP]: ({commit}, authData) => { var call = process.env.MONGODB_HOST + '/users'; console.log("CALL " + call); let params = { keyappid: process.env.PAO_APP_ID, + lang: state.user.lang, email: authData.email, password: authData.password, username: authData.username, + idapp: process.env.APP_ID, }; console.log(params); diff --git a/src/store/mutation-types.js b/src/store/mutation-types.js index c2bad87..7de31bd 100644 --- a/src/store/mutation-types.js +++ b/src/store/mutation-types.js @@ -1,3 +1,4 @@ + export const SET_VALUE = 'SET_VALUE'; export const SET_DEFFERED_PROMPT = 'defprompt'; export const SET_LOGIN_PAGE = 'setloginpage'; @@ -11,11 +12,11 @@ export const SET_FORM_SIGNUP = 'formsignup'; export const USER_REC = 'user_rec'; export const USER_USERNAME = 'username'; export const USER_EMAIL = 'email'; +export const USER_LANG = 'lang'; export const USER_PASSWORD = 'password'; export const USER_DATEOFBIRTH = 'dateofbirth'; export const USER_SIGNUP = 'signup'; - - +export const USER_VREG = 'vreg';