Bottone Registrati: manca getlang che non funziona....

This commit is contained in:
paolo
2018-11-12 18:08:06 +01:00
parent 0e383f3493
commit f5b73414b1
16 changed files with 87 additions and 59 deletions

2
.env
View File

@@ -8,4 +8,4 @@ MASTER_KEY='KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T'
LOGO_REG='quasar-logo-full.svg'
TEST_EMAIL='paolo.arena77@gmail.com'
TEST_USERNAME='paoloar77'
TEST_PASSWORD='mypassword'
TEST_PASSWORD='mypassword@1A'

View File

@@ -3,5 +3,6 @@ export const PayloadMessageTypes = {
info: 'Info',
failure: 'Failure',
success: 'Success',
warning: 'Warning'
warning: 'Warning',
statusfound: 200
}

View File

@@ -19,7 +19,7 @@ const addProp = (obj: {}, propName: string, value: string) => {
addProp(uri, 'auth', '/auth/')
addProp(uri, 'content', '/api/content/')
addProp(uri, 'site', '')
addProp(uri, 'site', process.env.MONGODB_HOST)
addProp(uri, 'services', '/api/')
const config = {

View File

@@ -23,6 +23,7 @@ const messages = {
email: 'dev\'essere una email valida',
errore_generico: 'Si prega di compilare correttamente i campi',
atleast: 'dev\'essere lungo almeno di',
complexity: 'deve contenere almeno 1 carattere minuscolo, 1 maiuscola e 1 cifra',
notmore: 'non dev\'essere lungo più di',
char: 'caratteri',
terms: 'Devi accettare le condizioni, per continuare.',
@@ -74,6 +75,7 @@ const messages = {
email: 'must be a valid email',
errore_generico: 'Please review fields again',
atleast: 'must be at least',
complexity: 'must contains at least 1 lowercase letter, 1 uppercase letter, and 1 digit',
notmore: 'must not be more than',
char: 'characters long',
terms: 'You need to agree with the terms & conditions.',

View File

@@ -1,4 +1,4 @@
export { IPayload } from './payload';
export { IPayloadMessage } from './payload-message';
export * from './payload-mapper';
export { IPayload } from './payload'
export { IPayloadMessage } from './payload-message'
export * from './payload-mapper'

View File

@@ -9,7 +9,6 @@ export class PayloadMapper {
private fromError<T>(o: Error): IPayload<T> {
return {
// @ts-ignore
data: null,
message: {
messageTypeId: PayloadMessageTypes.error,
@@ -21,7 +20,6 @@ export class PayloadMapper {
private fromAxiosError<T>(o: AxiosError): IPayload<T> {
// @ts-ignore
let data: T = null
if (o.response && isAxiosResponse(o.response))
@@ -39,7 +37,6 @@ export class PayloadMapper {
private fromAxiosResponse<T>(o: AxiosResponse): IPayload<T> {
// @ts-ignore
let value: IPayload<T> = null
if (isPayload<T>(o.data))
@@ -49,7 +46,6 @@ export class PayloadMapper {
data: <any>o.data,
message: {
messageTypeId: PayloadMessageTypes.success,
// @ts-ignore
text: null
}
}
@@ -67,7 +63,6 @@ export class PayloadMapper {
if (isAxiosResponse(o))
return this.fromAxiosResponse<T>(o)
// @ts-ignore
return null
}
}

View File

@@ -1,6 +1,6 @@
export interface IPayloadMessage {
text: string;
title?: string;
messageTypeId: string;
text: string
title?: string
messageTypeId: string
}

View File

@@ -10,7 +10,7 @@ const bcrypt = require('bcryptjs')
import * as types from '@/store/mutation-types'
import { serv_constants } from '@/store/modules/serv_constants'
import { IUserState } from '@/model'
import { ISignupOptions, IUserState } from '@/model'
import { ILinkReg, IResult, IIdToken } from '@/model/other'
@@ -39,7 +39,7 @@ class User extends VuexModule implements IUserState { // Non occorrono i gette
verifiedEmail: IUserState['verifiedEmail'] = false
servercode: number = 0
getlang (): any {
getlang() {
if (this.lang !== '') {
return this.lang
} else {
@@ -253,18 +253,21 @@ class User extends VuexModule implements IUserState { // Non occorrono i gette
})
}
@Action({ commit: types.USER_VREG })
signup (authData: IUserState) {
@Action({ commit: types.USER_SIGNUP })
signup (authData: ISignupOptions) {
let call = process.env.MONGODB_HOST + '/users'
console.log('CALL ' + call)
// console.log("PASSW: " + authData.password);
let mylang = this.getlang()
console.log('MYLANG: ' + mylang)
return bcrypt.hash(authData.password, bcrypt.genSaltSync(12))
.then((hashedPassword: string) => {
let usertosend = {
keyappid: process.env.PAO_APP_ID,
lang: this.getlang(),
lang: mylang,
email: authData.email,
password: String(hashedPassword),
username: authData.username,
@@ -350,7 +353,7 @@ class User extends VuexModule implements IUserState { // Non occorrono i gette
}
@Action({ commit: types.USER_SIGNIN })
signin (authData: IUserState) {
signin (authData: ISignupOptions) {
let call = process.env.MONGODB_HOST + '/users/login'
console.log('LOGIN ' + call)

View File

@@ -1,3 +1,4 @@
export { duplicate } from './duplicate'
export { registered } from './registered'
export { registereduser } from './registereduser'
export { registeredemail } from './registeredemail'
export { complexity } from './complexity'

View File

@@ -1,22 +0,0 @@
import { default as Axios, AxiosResponse } from 'axios'
import { IPayload } from '../model'
import { GlobalConfig, PayloadMessageTypes } from '../common'
const AUTH_URL = GlobalConfig.uri.auth
const VALIDATE_USER_URL = AUTH_URL + 'validateuser'
export function registered(userName: string) {
let config = {
params: { userName: userName }
}
let onSuccess = (res: AxiosResponse) => {
let payload: IPayload<boolean> = res.data
return payload.message.messageTypeId !== PayloadMessageTypes.failure
}
return Axios.get(VALIDATE_USER_URL, config)
.then(onSuccess)
}

View File

@@ -0,0 +1,19 @@
import { default as Axios, AxiosResponse } from 'axios'
import { GlobalConfig, PayloadMessageTypes } from '../common'
// const SITE_URL = GlobalConfig.uri.site
const VALIDATE_USER_URL = process.env.MONGODB_HOST + '/email/'
export function registeredemail(email: string) {
let onSuccess = (res: AxiosResponse) => {
return res.status !== PayloadMessageTypes.statusfound
}
return Axios.get(VALIDATE_USER_URL + email)
.then(onSuccess)
.catch((err) => {
return true
})
}

View File

@@ -0,0 +1,24 @@
import { default as Axios, AxiosResponse } from 'axios'
import { IPayload } from '@/model'
import { GlobalConfig, PayloadMessageTypes } from '../common'
// const SITE_URL = GlobalConfig.uri.site
const VALIDATE_USER_URL = process.env.MONGODB_HOST + '/users/'
export function registereduser(userName: string) {
let config = {
params: { userName: userName }
}
let onSuccess = (res: AxiosResponse) => {
return res.status !== PayloadMessageTypes.statusfound
}
return Axios.get(VALIDATE_USER_URL + config.params.userName)
.then(onSuccess)
.catch((err) => {
return true
})
}

View File

@@ -4,7 +4,7 @@
<div class="text-center">
<p>
<!--<img src="../../../assets/quasar-logo-full.svg">-->
<img :src="`../../../assets/`+`${env('LOGO_REG')}`">
<img src="../../../assets/{{ logoimg }}">
</p>
</div>

View File

@@ -1,7 +1,7 @@
import { ISignupOptions } from '@/model'
import { required, minLength, email, sameAs } from 'vuelidate/lib/validators'
import { ValidationRuleset } from 'vuelidate'
import { complexity, registered } from '@/validation'
import { complexity, registereduser, registeredemail } from '@/validation'
export type TSignup = { signup: ISignupOptions, validationGroup: string[] }
@@ -17,11 +17,12 @@ export const validations = {
},
username: {
required,
registered
registereduser
},
email: {
required,
email
email,
registeredemail
},
terms: {
required

View File

@@ -10,7 +10,6 @@ import { validations, TSignup } from './signup-validate'
import { validationMixin } from 'vuelidate'
import './signup.scss'
import { complexity, registered } from '@/validation'
// import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar'
@@ -46,6 +45,10 @@ export default class Signup extends Vue {
}
}
public logoimg() {
return process.env.LOGO_REG
}
get allowSubmit() {
let error = this.$v.$error || this.$v.$invalid
@@ -88,7 +91,7 @@ export default class Signup extends Vue {
}
}, */
env() {
public env() {
return process.env
}
@@ -117,6 +120,7 @@ export default class Signup extends Vue {
}
if (!item.required) return this.$t('reg.err.required')
if (!item.complexity) return this.$t('reg.err.complexity')
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 ''
@@ -139,7 +143,7 @@ export default class Signup extends Vue {
}
submit() {
public submitOk() {
this.$v.signup.$touch()
this.duplicate_email = false
@@ -167,8 +171,6 @@ export default class Signup extends Vue {
this.$q.loading.hide()
})
// ...
}
}

View File

@@ -3,7 +3,7 @@
<div class="text-center">
<p>
<!--<img src="../../../assets/quasar-logo-full.svg">-->
<img :src="`../../../assets/`+`${env('LOGO_REG')}`">
<img :src="`../../../assets/${logoimg()}`">
</p>
</div>
@@ -76,13 +76,15 @@
:label="$t('reg.terms')"></q-checkbox>
</q-field>
<br>
<q-btn rounded size="lg" color="primary" @click="submitOk" :disabled='!allowSubmit'>{{$t('reg.submit')}}
</q-btn>
<!--
<div align="center">
<q-btn rounded size="lg" color="primary" @click="submit" :disable="">{{$t('reg.submit')}}
<q-btn rounded size="lg" color="primary" @click="submitOk" :disable="">{{$t('reg.submit')}}
</q-btn>
</div>