Login e Token OK

This commit is contained in:
paolo
2018-10-26 22:25:35 +02:00
parent 28eb3ff6a8
commit 338a8a4107
11 changed files with 196 additions and 82 deletions

View File

@@ -25,10 +25,12 @@
<q-select class="sel_lang" v-model="lang" stack-label="" :options="selectOpLang"/>
<!--<message-popover></message-popover>-->
<!--
<div class="right-itens">
<!--<message-popover></message-popover>-->
<label>{{ $t('msg.hello') }}</label> <span v-model="prova"></span> !
</div>
</div>-->
</q-toolbar>
@@ -57,7 +59,9 @@
import user from '../store/modules/user';
import {mapGetters} from 'vuex'
import * as types from '../store/mutation-types'
import {mapGetters, mapActions} from 'vuex'
export default {
components: {

View File

@@ -1,18 +1,19 @@
<template>
<div>
<div id="profile">
<div id="profile" v-if="getUsername">
<img :src="photo" style='height: 80px' class="inline-block">
<img src="../img/avatar-1.svg" id="avatar" class="inline-block">
<div id="user-name">
<span class="text-white"> Username: {{ getUsername }} </span>
<hr>
<span class="text-white"> {{ email }} </span>
<span class="text-white"> {{ getUsername }} </span>
<hr>
<span class="text-white" v-if="getVerificato"> {{$t('reg.verificato')}} </span>
<span class="text-white" v-else> {{$t('reg.non_verificato')}} </span>
<span class="text-white"> {{ getEmail }} </span>
</div>
<div id="user-actions">
<button class="bordered blue small"><i>person</i></button>
<button class="bordered blue small"><i>lock</i></button>
<button class="bordered blue small" @click='logOut'><i>exit_to_app</i></button>
<q-btn round color="primary" icon="person"></q-btn>
<q-btn round color="warning" icon="lock"></q-btn>
<q-btn round color="secondary" icon="exit_to_app" @click='logoutHandler'></q-btn>
</div>
</div>
@@ -20,27 +21,24 @@
<menu-two v-else :links="links"></menu-two>
<div class="fixed-bottom text-center light text-italic">
Powered by
<a href="https://vuejs.org/"><img src="../img/vue-logo.png" alt=""></a>
<a href="http://quasar-framework.org/"><img src="../img/quasar-logo.png" alt=""></a>
Powered by Perseo
</div>
</div>
</template>
<script type="text/javascript">
import {mapGetters} from 'vuex'
import menuOne from './menuOne.vue'
import menuTwo from './menuTwo.vue'
//import firebase from 'firebase'
import * as types from '../../../store/mutation-types'
import {mapGetters, mapActions} from 'vuex'
export default {
data() {
return {
photo: '',
userId: '',
name: '',
email: '',
user: {},
user: null,
links: {
Dashboard: {
routes: [
@@ -71,7 +69,6 @@
}
},
created() {
console.log("CREA DRAWER!!!!!!!!")
var vm = this
/*firebase.auth().onAuthStateChanged(function (user) {
if (user) {
@@ -83,14 +80,16 @@
}
})*/
},
methods: {
logOut() {
//firebase.auth().signOut()
methods:{
...mapActions("user", ["logout"]),
logoutHandler() {
this.logout({router: this.$router});
this.$q.notify(this.$t('logout.uscito'));
}
},
computed: {
...mapGetters("glob", ['getLayoutNeeded', 'getMenuCollapse']),
...mapGetters("user", ['getUsername'])
...mapGetters("user", ['getUsername', 'getVerificato', 'getEmail']),
},
components: {
menuOne,

View File

@@ -27,9 +27,5 @@
created () {
},
methods: {
logOut () {
}
}
}
</script>

View File

@@ -1,6 +1,6 @@
<template>
<div>
<q-page padding class="">
<q-page padding class="signin">
<div class="text-center">
<p>
<!--<img src="../../../assets/quasar-logo-full.svg">-->
@@ -63,6 +63,8 @@
import {serv_constants} from "../../../store/modules/serv_constants";
import axios from 'axios';
import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar'
export default {
data() {
@@ -100,6 +102,9 @@
...mapActions("user", {
signin: types.USER_SIGNIN,
}),
showNotif (msg) {
this.$q.notify(msg)
},
errorMsg(cosa, item) {
try {
if (!item.$error) return '';
@@ -116,12 +121,13 @@
checkErrors(riscode) {
//console.log("RIS = " + riscode);
if (riscode === Errori_MongoDb.OK) {
this.showNotif({type: 'positive', message: this.$t('login.completato')});
this.$router.push('/');
}else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) {
this.$q.notify(this.$t('login.errato'));
} else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) {
this.showNotif(this.$t('login.errato'));
this.$router.push('/signin');
} else {
this.$q.notify("Errore num " + riscode);
this.showNotif("Errore num " + riscode);
}
},
@@ -129,21 +135,33 @@
this.$v.form.$touch();
if (this.$v.form.$error) {
this.$q.notify(this.$t('reg.err.errore_generico'));
this.showNotif(this.$t('reg.err.errore_generico'));
return
}
this.$q.loading.show({message: this.$t('login.incorso')});
console.log(this.form);
this.signin(this.form)
.then((riscode) => {
this.checkErrors(riscode);
this.$q.loading.hide();
}).catch(error => {
console.log("ERROR = " + error);
this.$q.loading.hide();
});
// ...
}
},
}
</script>
<style scoped>
.signin {
width: 100%;
margin: 0 auto;
max-width: 450px;
}
</style>

View File

@@ -1,6 +1,6 @@
<template>
<div>
<q-page padding class="">
<q-page padding class="signup">
<div class="text-center">
<p>
<!--<img src="../../../assets/quasar-logo-full.svg">-->
@@ -81,10 +81,13 @@
/>
</q-field>
<br>
<div align="center">
<q-btn rounded size="lg" color="primary" @click="submit" :disable="$v.$error">{{$t('reg.submit')}}
</q-btn>
</div>
</q-page>
</div>
</template>
@@ -107,6 +110,8 @@
import {Errori_MongoDb} from '../../../store/modules/user'
import axios from 'axios';
import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar'
export default {
data() {
@@ -178,6 +183,9 @@
...mapActions("user", {
signup: types.USER_SIGNUP,
}),
showNotif(msg) {
this.$q.notify(msg)
},
errorMsg(cosa, item) {
try {
if (!item.$error) return '';
@@ -209,13 +217,13 @@
checkErrors(riscode) {
//console.log("RIS = " + riscode);
if (riscode === Errori_MongoDb.DUPLICATE_EMAIL_ID) {
this.$q.notify(this.$t('reg.err.duplicate_email'));
this.showNotif(this.$t('reg.err.duplicate_email'));
} else if (riscode === Errori_MongoDb.DUPLICATE_USERNAME_ID) {
this.$q.notify(this.$t('reg.err.duplicate_username'));
this.showNotif(this.$t('reg.err.duplicate_username'));
} else if (riscode === Errori_MongoDb.OK) {
this.$router.push('/');
} else {
this.$q.notify("Errore num " + riscode);
this.showNotif("Errore num " + riscode);
}
},
@@ -226,25 +234,38 @@
this.duplicate_username = false;
if (!this.form.terms) {
this.$q.notify(this.$t('reg.err.terms'));
this.showNotif(this.$t('reg.err.terms'));
return
}
if (this.$v.form.$error) {
this.$q.notify(this.$t('reg.err.errore_generico'));
this.showNotif(this.$t('reg.err.errore_generico'));
return
}
this.$q.loading.show({message: this.$t('reg.incorso')});
console.log(this.form);
this.signup(this.form)
.then((riscode) => {
this.checkErrors(riscode);
this.$q.loading.hide();
}).catch(error => {
console.log("ERROR = " + error);
this.$q.loading.hide();
});
// ...
}
},
}
</script>
<style scoped>
.signup {
width: 100%;
margin: 0 auto;
max-width: 450px;
}
</style>

View File

@@ -65,6 +65,13 @@
this.risultato = ris.msg;
console.log("RIS = ");
console.log(ris);
if (this.verificatook) {
setTimeout(() => {
this.$router.replace('/');
}, 3000)
}
}).catch((err) => {
console.log("ERR = " + err);
});