Risolto problema che non loggava correttamente

This commit is contained in:
paolo
2018-12-06 20:07:51 +01:00
parent 45be1e02c5
commit 056dfc16f4
17 changed files with 203 additions and 187 deletions

View File

@@ -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()
})
}
}