diff --git a/.env b/.env index 79519a9..fd343b7 100644 --- a/.env +++ b/.env @@ -6,6 +6,6 @@ MONGODB_HOST='http://localhost:3000' PAO_APP_ID='KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF' MASTER_KEY='KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T' LOGO_REG='quasar-logo-full.svg' -TEST_EMAIL='paolo.arena77@gmail.com' +TEST_EMAIL=paolo.arena77@gmail.com TEST_USERNAME='paoloar77' TEST_PASSWORD='mypassword@1A' diff --git a/package.json b/package.json index 0ef61ce..c8a214a 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "dev": "NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev", "dev:ssr": "NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m ssr", "dev:pwa": "NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m pwa", + "pwa": "NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m pwa", "test:unit": "jest", "test:cover": "jest --coverage", "build": "quasar build", diff --git a/quasar.conf.js b/quasar.conf.js index 7bb2755..485d852 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -98,7 +98,7 @@ module.exports = function (ctx) { devServer: { https: false, port: 8080, - open: true // opens browser window automatically + open: false // opens browser window automatically }, // framework: 'all' --- includes everything; for dev only! framework: { diff --git a/src/layouts/drawer/drawer.vue b/src/layouts/drawer/drawer.vue index fdc609a..b19adc1 100644 --- a/src/layouts/drawer/drawer.vue +++ b/src/layouts/drawer/drawer.vue @@ -1,5 +1,6 @@ - - - - diff --git a/src/views/login/signin/signin-validate.ts b/src/views/login/signin/signin-validate.ts new file mode 100644 index 0000000..9c35d31 --- /dev/null +++ b/src/views/login/signin/signin-validate.ts @@ -0,0 +1,17 @@ +import { ISigninOptions } from 'model' +import { required, minLength, email, sameAs } from 'vuelidate/lib/validators' + +export type TSignin = { signin: ISigninOptions, validationGroup: string[] } + +export const validations = { + signin: { + password: { + required, + minLength: minLength(8) + }, + username: { + required, + minLength: minLength(6) + } + } +} diff --git a/src/views/login/signin/signin.scss b/src/views/login/signin/signin.scss new file mode 100644 index 0000000..7ce52a9 --- /dev/null +++ b/src/views/login/signin/signin.scss @@ -0,0 +1,5 @@ +.signin { + width: 100%; + margin: 0 auto; + max-width: 450px; +} diff --git a/src/views/login/signin/signin.ts b/src/views/login/signin/signin.ts new file mode 100644 index 0000000..4cd6e87 --- /dev/null +++ b/src/views/login/signin/signin.ts @@ -0,0 +1,103 @@ +import Vue from 'vue' +import { Component, Prop, Watch } from 'vue-property-decorator' +import { UserStore } from '@store' +import { rescodes } from '../../../store/Modules/rescodes' +import { serv_constants } from '../../../store/Modules/serv_constants' + + +import { ISigninOptions, IUserState } from 'model' +import { validations, TSignin } from './signin-validate' + +import { validationMixin } from 'vuelidate' + +import './signin.scss' + +// import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar' + + +@Component({ + mixins: [validationMixin], + validations: validations +}) + +export default class Signin extends Vue { + public $v + public $q + $t: any + + public signin: ISigninOptions = { + username: process.env.TEST_USERNAME || '', + password: process.env.TEST_PASSWORD + } + + + created() { + this.$v.$reset() + } + + public env() { + return process.env + } + + public logoimg() { + return process.env.LOGO_REG + } + + showNotif(msg: any) { + this.$q.notify(msg) + } + + public getlinkforgetpwd() { + return '/requestresetpwd' + } + + public errorMsg(cosa: string, item: any) { + try { + if (!item.$error) return '' + if (item.$params.email && !item.email) return this.$t('reg.err.email') + + 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') + return '' + } catch (error) { + // console.log("ERR : " + error); + } + } + + checkErrors(riscode) { + // console.log("RIS = " + riscode); + if (riscode === rescodes.OK) { + this.showNotif({ type: 'positive', message: this.$t('login.completato') }) + this.$router.push('/') + } else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) { + this.showNotif(this.$t('login.errato')) + this.$router.push('/signin') + } else { + this.showNotif('Errore num ' + riscode) + } + + } + + submit() { + this.$v.signin.$touch() + + if (this.$v.signin.$error) { + this.showNotif(this.$t('reg.err.errore_generico')) + return + } + + this.$q.loading.show({ message: this.$t('login.incorso') }) + + console.log(this.signin) + UserStore.actions.signin(this.signin) + .then((riscode) => { + this.checkErrors(riscode) + this.$q.loading.hide() + }).catch(error => { + console.log('ERROR = ' + error) + this.$q.loading.hide() + }) + + } +} diff --git a/src/views/login/signin/signin.vue b/src/views/login/signin/signin.vue new file mode 100644 index 0000000..09fd7c6 --- /dev/null +++ b/src/views/login/signin/signin.vue @@ -0,0 +1,56 @@ + + + diff --git a/src/views/login/signup/signup-validate.ts b/src/views/login/signup/signup-validate.ts index 0024be5..252d891 100644 --- a/src/views/login/signup/signup-validate.ts +++ b/src/views/login/signup/signup-validate.ts @@ -1,4 +1,4 @@ -import { ISignupOptions } from '@/model' +import { ISignupOptions } from 'model' import { required, minLength, email, sameAs } from 'vuelidate/lib/validators' import { ValidationRuleset } from 'vuelidate' import { complexity, registereduser, registeredemail } from '@/validation' diff --git a/src/views/login/signup/signup.ts b/src/views/login/signup/signup.ts index f7f2c39..e2e573a 100644 --- a/src/views/login/signup/signup.ts +++ b/src/views/login/signup/signup.ts @@ -3,7 +3,6 @@ import { Component, Prop, Watch } from 'vue-property-decorator' import { UserStore } from '@store' import { rescodes } from '../../../store/Modules/rescodes' -import { required, email, numeric, maxLength, maxValue, minValue, sameAs, minLength } from 'vuelidate/lib/validators' import { ISignupOptions, IUserState } from 'model' import { validations, TSignup } from './signup-validate'