2018-10-26 00:30:10 +02:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2018-10-26 22:25:35 +02:00
|
|
|
<q-page padding class="signin">
|
2018-10-26 00:30:10 +02:00
|
|
|
<div class="text-center">
|
|
|
|
|
<p>
|
|
|
|
|
<!--<img src="../../../assets/quasar-logo-full.svg">-->
|
2018-11-12 18:08:06 +01:00
|
|
|
<img src="../../../assets/{{ logoimg }}">
|
2018-10-26 00:30:10 +02:00
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!--Prova URL : {{env('PROVA_PAOLO')}}-->
|
|
|
|
|
|
|
|
|
|
<q-field
|
|
|
|
|
:error="$v.form.username.$error"
|
|
|
|
|
:error-label="`${errorMsg('username', $v.form.username)}`"
|
|
|
|
|
>
|
|
|
|
|
<q-input
|
|
|
|
|
:value="form.username"
|
2018-11-02 15:56:29 +01:00
|
|
|
autocomplete="username"
|
2018-10-26 00:30:10 +02:00
|
|
|
@change="val => { form.username = val }"
|
|
|
|
|
:before="[{icon: 'person', handler () {}}]"
|
|
|
|
|
@blur="$v.form.username.$touch"
|
|
|
|
|
:error="$v.form.username.$error"
|
|
|
|
|
:float-label="$t('reg.username')"
|
|
|
|
|
/>
|
|
|
|
|
</q-field>
|
|
|
|
|
|
|
|
|
|
<q-field
|
|
|
|
|
:error="$v.form.password.$error"
|
|
|
|
|
:error-label="`${errorMsg('password', $v.form.password)}`"
|
|
|
|
|
>
|
|
|
|
|
<q-input
|
|
|
|
|
v-model="form.password"
|
|
|
|
|
:before="[{icon: 'vpn_key', handler () {}}]"
|
|
|
|
|
@blur="$v.form.password.$touch"
|
|
|
|
|
:error="$v.form.password.$error"
|
|
|
|
|
:float-label="$t('reg.password')"
|
|
|
|
|
/>
|
|
|
|
|
</q-field>
|
|
|
|
|
|
2018-11-02 15:56:29 +01:00
|
|
|
<div>
|
|
|
|
|
<a :href="getlinkforgetpwd">{{$t('reg.forgetpassword')}}</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
2018-10-26 00:30:10 +02:00
|
|
|
<br>
|
|
|
|
|
|
|
|
|
|
<div align="center">
|
|
|
|
|
<q-btn rounded size="lg" color="primary" @click="submit" :disable="$v.$error">{{$t('login.enter')}}
|
|
|
|
|
</q-btn>
|
|
|
|
|
</div>
|
|
|
|
|
</q-page>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import {
|
|
|
|
|
required,
|
|
|
|
|
email,
|
|
|
|
|
minLength,
|
|
|
|
|
maxLength,
|
|
|
|
|
sameAs,
|
|
|
|
|
} from 'vuelidate/lib/validators'
|
|
|
|
|
|
|
|
|
|
import {mapGetters, mapActions} from 'vuex'
|
2018-11-08 01:09:33 +01:00
|
|
|
import * as types from '../../store/mutation-types'
|
2018-10-26 00:30:10 +02:00
|
|
|
|
2018-11-02 23:22:16 +01:00
|
|
|
//import {ErroriMongoDb} from '../../store/modules/user'
|
2018-11-08 01:09:33 +01:00
|
|
|
import {serv_constants} from "../../store/modules/serv_constants";
|
2018-10-26 00:30:10 +02:00
|
|
|
import axios from 'axios';
|
|
|
|
|
|
2018-10-26 22:25:35 +02:00
|
|
|
import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar'
|
|
|
|
|
|
2018-10-26 00:30:10 +02:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
url: process.env.VUE_APP_URL,
|
|
|
|
|
form: {
|
|
|
|
|
username: process.env.TEST_USERNAME,
|
|
|
|
|
password: process.env.TEST_PASSWORD,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
...mapGetters("user", [
|
|
|
|
|
'getUsername',
|
|
|
|
|
'getPassword',
|
|
|
|
|
]),
|
|
|
|
|
...mapGetters("user", [
|
|
|
|
|
'getUserServer',
|
|
|
|
|
'getServerCode',
|
|
|
|
|
]),
|
|
|
|
|
env() {
|
|
|
|
|
return env
|
|
|
|
|
},
|
2018-11-02 15:56:29 +01:00
|
|
|
getlinkforgetpwd () {
|
|
|
|
|
return "/requestresetpwd";
|
|
|
|
|
},
|
2018-10-26 00:30:10 +02:00
|
|
|
},
|
|
|
|
|
validations: {
|
|
|
|
|
isAsync: true,
|
|
|
|
|
form: {
|
|
|
|
|
password: {required, minLength: minLength(8), maxLength: maxLength(20)},
|
|
|
|
|
username: {
|
|
|
|
|
required, minLength: minLength(6), maxLength: maxLength(20),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
...mapActions("user", {
|
|
|
|
|
signin: types.USER_SIGNIN,
|
|
|
|
|
}),
|
2018-10-26 22:25:35 +02:00
|
|
|
showNotif (msg) {
|
|
|
|
|
this.$q.notify(msg)
|
|
|
|
|
},
|
2018-10-26 00:30:10 +02:00
|
|
|
errorMsg(cosa, item) {
|
|
|
|
|
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);
|
2018-11-02 22:15:48 +01:00
|
|
|
if (riscode === ErroriMongoDb.OK) {
|
2018-10-26 22:25:35 +02:00
|
|
|
this.showNotif({type: 'positive', message: this.$t('login.completato')});
|
2018-10-26 00:30:10 +02:00
|
|
|
this.$router.push('/');
|
2018-10-26 22:25:35 +02:00
|
|
|
} else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) {
|
|
|
|
|
this.showNotif(this.$t('login.errato'));
|
2018-10-26 00:30:10 +02:00
|
|
|
this.$router.push('/signin');
|
|
|
|
|
} else {
|
2018-10-26 22:25:35 +02:00
|
|
|
this.showNotif("Errore num " + riscode);
|
2018-10-26 00:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
submit() {
|
|
|
|
|
this.$v.form.$touch();
|
|
|
|
|
|
|
|
|
|
if (this.$v.form.$error) {
|
2018-10-26 22:25:35 +02:00
|
|
|
this.showNotif(this.$t('reg.err.errore_generico'));
|
2018-10-26 00:30:10 +02:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-26 22:25:35 +02:00
|
|
|
this.$q.loading.show({message: this.$t('login.incorso')});
|
|
|
|
|
|
2018-10-26 00:30:10 +02:00
|
|
|
console.log(this.form);
|
|
|
|
|
this.signin(this.form)
|
|
|
|
|
.then((riscode) => {
|
|
|
|
|
this.checkErrors(riscode);
|
2018-10-26 22:25:35 +02:00
|
|
|
this.$q.loading.hide();
|
2018-10-26 00:30:10 +02:00
|
|
|
}).catch(error => {
|
|
|
|
|
console.log("ERROR = " + error);
|
2018-10-26 22:25:35 +02:00
|
|
|
this.$q.loading.hide();
|
2018-10-26 00:30:10 +02:00
|
|
|
});
|
|
|
|
|
|
2018-10-26 22:25:35 +02:00
|
|
|
|
2018-10-26 00:30:10 +02:00
|
|
|
// ...
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2018-10-26 22:25:35 +02:00
|
|
|
<style scoped>
|
|
|
|
|
.signin {
|
|
|
|
|
width: 100%;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
max-width: 450px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|