diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index e3364dfb..f5eb5368 100755 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -62,6 +62,10 @@ const webpackDevConfig = { new webpack.NamedModulesPlugin(), ], devServer: { + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': '*', + }, /* headers: { 'Access-Control-Allow-Origin': '*', diff --git a/quasar.conf.js b/quasar.conf.js index 3b84ed10..274ad772 100755 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -149,6 +149,10 @@ module.exports = configure((ctx) => ({ https: false, port: 8084, open: false, // opens browser window automatically + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': '*', + }, }, // https://v2.quasar.dev/quasar-cli/quasar-conf-js#Property%3A-framework diff --git a/src/boot/axios.ts b/src/boot/axios.ts index 2242db9b..70414ac9 100755 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -1,19 +1,24 @@ import axios from 'axios' import { boot } from 'quasar/wrappers' -const api = axios.create({ baseURL: process.env.MONGODB_HOST }) +const api = axios.create({ + baseURL: process.env.MONGODB_HOST, + headers: { + 'Content-type': 'application/json', + }, +}) export default boot(({ app }) => { -// for use inside Vue files (Options API) through this.$axios and this.$api + // for use inside Vue files (Options API) through this.$axios and this.$api app.config.globalProperties.$axios = axios // ^ ^ ^ this will allow you to use this.$axios (for Vue Options API form) // so you won't necessarily have to import axios in each vue file app.config.globalProperties.$api = api -// ^ ^ ^ this will allow you to use this.$api (for Vue Options API form) -// so you can easily perform requests against your app's API -// + // ^ ^ ^ this will allow you to use this.$api (for Vue Options API form) + // so you can easily perform requests against your app's API + // }) export { axios } diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js index aff39612..24e2f515 100755 --- a/src/statics/lang/it.js +++ b/src/statics/lang/it.js @@ -593,6 +593,7 @@ const msg_it = { char: 'caratteri', terms: 'Devi accettare le condizioni, per continuare.', email_not_exist: 'l\'Email non è presente in archivio, verificare se è corretta', + code_resetpwd_error: 'Il codice inserito non è corretto.', duplicate_email: 'l\'Email è già stata registrata', invalid_email: 'l\'Email non è valida', user_already_exist: 'La registrazione con questi dati (nome, cognome e cellulare) è stata già effettuata. Per accedere al sito, cliccare sul bottone LOGIN dalla HomePage.', @@ -645,12 +646,14 @@ const msg_it = { reset: { title_reset_pwd: 'Reimposta la tua Password', send_reset_pwd: 'Invia Reimposta la password', + resend_reset_pwd: 'Rimanda nuovamente', incorso: 'Richiesta Nuova Email...', email_sent: 'Email inviata', check_email: 'Controlla la tua email, ti arriverà un messaggio con un link per reimpostare la tua password. Questo link, per sicurezza, scadrà dopo 4 ore.', token_scaduto: 'Il token è scaduto oppure è stato già usato. Ripetere la procedura di reset password', title_update_pwd: 'Aggiorna la tua password', update_password: 'Aggiorna Password', + confirmcode_reset: 'Conferma Codice', }, logout: { uscito: 'Sei Uscito', diff --git a/src/store/UserStore.ts b/src/store/UserStore.ts index baf1ce62..9aa81ff1 100755 --- a/src/store/UserStore.ts +++ b/src/store/UserStore.ts @@ -573,13 +573,14 @@ export const useUserStore = defineStore('UserStore', { async requestpwd(paramquery: any) { const usertosend = { email: paramquery.email, + codetocheck: paramquery.tokenforgot_code, } console.log(usertosend) this.setServerCode(tools.CALLING) return Api.SendReq('/requestnewpwd', 'POST', usertosend) - .then((res) => ({ code: res.data.code, msg: res.data.msg })).catch((error) => { + .then((res) => ({ code: res.data.code, msg: res.data.msg, link: res.data.link })).catch((error) => { this.setErrorCatch(error) return this.getServerCode }) diff --git a/src/views/requestresetpwd/requestresetpwd.ts b/src/views/requestresetpwd/requestresetpwd.ts index ce2f94c4..bb3ce679 100755 --- a/src/views/requestresetpwd/requestresetpwd.ts +++ b/src/views/requestresetpwd/requestresetpwd.ts @@ -4,13 +4,14 @@ import { tools } from '@store/Modules/tools' import { Logo } from '../../components/logo' import { CTitleBanner } from '../../components/CTitleBanner' -import { defineComponent, reactive, ref } from 'vue' +import { defineComponent, reactive, ref, watch } from 'vue' import { useI18n } from '@src/boot/i18n' import { useUserStore } from '@store/UserStore' import { useGlobalStore } from '@store/globalStore' import { useQuasar } from 'quasar' import useVuelidate from '@vuelidate/core' import { validations } from '@src/views/requestresetpwd/request-resetpwd-validate' +import { useRouter } from 'vue-router' export default defineComponent({ @@ -22,6 +23,8 @@ export default defineComponent({ const userStore = useUserStore() const globalStore = useGlobalStore() + const $router = useRouter() + const emailsent = ref(false) const form = reactive({ email: '', @@ -34,6 +37,10 @@ export default defineComponent({ const emailRef = ref(null) + watch(() => form.tokenforgot_code, (to: any, from: any) => { + checkCode() + }) + function emailinviata() { return emailsent.value } @@ -69,12 +76,36 @@ export default defineComponent({ tools.showNegativeNotif($q, t('reg.err.email_not_exist')) $q.loading.hide() }).catch((err: any) => { - console.log('ERROR = ' + err.error) - $q.loading.hide() - }) + console.log('ERROR = ' + err.error) + $q.loading.hide() + }) } + function checkCode() { + + const mycode = form.tokenforgot_code.trim() + if (mycode.length === 6) { + $q.loading.show({ message: t('reset.incorso') }) + // Check if code is correct + userStore.requestpwd(form) + .then((ris: any) => { + if (ris.code === serv_constants.RIS_CODE_OK) { + if (ris.link) + $router.replace(ris.link) + } else { + tools.showNegativeNotif($q, t('reg.err.code_resetpwd_error')) + } + form.tokenforgot_code = '' + $q.loading.hide() + }).catch((err: any) => { + console.log('ERROR = ' + err.error) + $q.loading.hide() + }) + + } + } + return { emailinviata, submit, @@ -82,6 +113,7 @@ export default defineComponent({ emailRef, v$, tools, + checkCode, } } }) diff --git a/src/views/requestresetpwd/requestresetpwd.vue b/src/views/requestresetpwd/requestresetpwd.vue index 1b1d2d9f..4193db31 100755 --- a/src/views/requestresetpwd/requestresetpwd.vue +++ b/src/views/requestresetpwd/requestresetpwd.vue @@ -1,60 +1,88 @@