Bottone Registrati: manca getlang che non funziona....
This commit is contained in:
2
.env
2
.env
@@ -8,4 +8,4 @@ MASTER_KEY='KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T'
|
|||||||
LOGO_REG='quasar-logo-full.svg'
|
LOGO_REG='quasar-logo-full.svg'
|
||||||
TEST_EMAIL='paolo.arena77@gmail.com'
|
TEST_EMAIL='paolo.arena77@gmail.com'
|
||||||
TEST_USERNAME='paoloar77'
|
TEST_USERNAME='paoloar77'
|
||||||
TEST_PASSWORD='mypassword'
|
TEST_PASSWORD='mypassword@1A'
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ export const PayloadMessageTypes = {
|
|||||||
info: 'Info',
|
info: 'Info',
|
||||||
failure: 'Failure',
|
failure: 'Failure',
|
||||||
success: 'Success',
|
success: 'Success',
|
||||||
warning: 'Warning'
|
warning: 'Warning',
|
||||||
}
|
statusfound: 200
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const addProp = (obj: {}, propName: string, value: string) => {
|
|||||||
|
|
||||||
addProp(uri, 'auth', '/auth/')
|
addProp(uri, 'auth', '/auth/')
|
||||||
addProp(uri, 'content', '/api/content/')
|
addProp(uri, 'content', '/api/content/')
|
||||||
addProp(uri, 'site', '')
|
addProp(uri, 'site', process.env.MONGODB_HOST)
|
||||||
addProp(uri, 'services', '/api/')
|
addProp(uri, 'services', '/api/')
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ const messages = {
|
|||||||
email: 'dev\'essere una email valida',
|
email: 'dev\'essere una email valida',
|
||||||
errore_generico: 'Si prega di compilare correttamente i campi',
|
errore_generico: 'Si prega di compilare correttamente i campi',
|
||||||
atleast: 'dev\'essere lungo almeno di',
|
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',
|
notmore: 'non dev\'essere lungo più di',
|
||||||
char: 'caratteri',
|
char: 'caratteri',
|
||||||
terms: 'Devi accettare le condizioni, per continuare.',
|
terms: 'Devi accettare le condizioni, per continuare.',
|
||||||
@@ -74,6 +75,7 @@ const messages = {
|
|||||||
email: 'must be a valid email',
|
email: 'must be a valid email',
|
||||||
errore_generico: 'Please review fields again',
|
errore_generico: 'Please review fields again',
|
||||||
atleast: 'must be at least',
|
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',
|
notmore: 'must not be more than',
|
||||||
char: 'characters long',
|
char: 'characters long',
|
||||||
terms: 'You need to agree with the terms & conditions.',
|
terms: 'You need to agree with the terms & conditions.',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export { IPayload } from './payload';
|
export { IPayload } from './payload'
|
||||||
export { IPayloadMessage } from './payload-message';
|
export { IPayloadMessage } from './payload-message'
|
||||||
export * from './payload-mapper';
|
export * from './payload-mapper'
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ export class PayloadMapper {
|
|||||||
private fromError<T>(o: Error): IPayload<T> {
|
private fromError<T>(o: Error): IPayload<T> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// @ts-ignore
|
|
||||||
data: null,
|
data: null,
|
||||||
message: {
|
message: {
|
||||||
messageTypeId: PayloadMessageTypes.error,
|
messageTypeId: PayloadMessageTypes.error,
|
||||||
@@ -21,7 +20,6 @@ export class PayloadMapper {
|
|||||||
|
|
||||||
private fromAxiosError<T>(o: AxiosError): IPayload<T> {
|
private fromAxiosError<T>(o: AxiosError): IPayload<T> {
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
let data: T = null
|
let data: T = null
|
||||||
|
|
||||||
if (o.response && isAxiosResponse(o.response))
|
if (o.response && isAxiosResponse(o.response))
|
||||||
@@ -39,7 +37,6 @@ export class PayloadMapper {
|
|||||||
|
|
||||||
private fromAxiosResponse<T>(o: AxiosResponse): IPayload<T> {
|
private fromAxiosResponse<T>(o: AxiosResponse): IPayload<T> {
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
let value: IPayload<T> = null
|
let value: IPayload<T> = null
|
||||||
|
|
||||||
if (isPayload<T>(o.data))
|
if (isPayload<T>(o.data))
|
||||||
@@ -49,7 +46,6 @@ export class PayloadMapper {
|
|||||||
data: <any>o.data,
|
data: <any>o.data,
|
||||||
message: {
|
message: {
|
||||||
messageTypeId: PayloadMessageTypes.success,
|
messageTypeId: PayloadMessageTypes.success,
|
||||||
// @ts-ignore
|
|
||||||
text: null
|
text: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,7 +63,6 @@ export class PayloadMapper {
|
|||||||
if (isAxiosResponse(o))
|
if (isAxiosResponse(o))
|
||||||
return this.fromAxiosResponse<T>(o)
|
return this.fromAxiosResponse<T>(o)
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
export interface IPayloadMessage {
|
export interface IPayloadMessage {
|
||||||
text: string;
|
text: string
|
||||||
title?: string;
|
title?: string
|
||||||
messageTypeId: string;
|
messageTypeId: string
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ const bcrypt = require('bcryptjs')
|
|||||||
import * as types from '@/store/mutation-types'
|
import * as types from '@/store/mutation-types'
|
||||||
import { serv_constants } from '@/store/modules/serv_constants'
|
import { serv_constants } from '@/store/modules/serv_constants'
|
||||||
|
|
||||||
import { IUserState } from '@/model'
|
import { ISignupOptions, IUserState } from '@/model'
|
||||||
import { ILinkReg, IResult, IIdToken } from '@/model/other'
|
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
|
verifiedEmail: IUserState['verifiedEmail'] = false
|
||||||
servercode: number = 0
|
servercode: number = 0
|
||||||
|
|
||||||
getlang (): any {
|
getlang() {
|
||||||
if (this.lang !== '') {
|
if (this.lang !== '') {
|
||||||
return this.lang
|
return this.lang
|
||||||
} else {
|
} else {
|
||||||
@@ -253,18 +253,21 @@ class User extends VuexModule implements IUserState { // Non occorrono i gette
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@Action({ commit: types.USER_VREG })
|
@Action({ commit: types.USER_SIGNUP })
|
||||||
signup (authData: IUserState) {
|
signup (authData: ISignupOptions) {
|
||||||
let call = process.env.MONGODB_HOST + '/users'
|
let call = process.env.MONGODB_HOST + '/users'
|
||||||
console.log('CALL ' + call)
|
console.log('CALL ' + call)
|
||||||
|
|
||||||
// console.log("PASSW: " + authData.password);
|
// console.log("PASSW: " + authData.password);
|
||||||
|
|
||||||
|
let mylang = this.getlang()
|
||||||
|
console.log('MYLANG: ' + mylang)
|
||||||
|
|
||||||
return bcrypt.hash(authData.password, bcrypt.genSaltSync(12))
|
return bcrypt.hash(authData.password, bcrypt.genSaltSync(12))
|
||||||
.then((hashedPassword: string) => {
|
.then((hashedPassword: string) => {
|
||||||
let usertosend = {
|
let usertosend = {
|
||||||
keyappid: process.env.PAO_APP_ID,
|
keyappid: process.env.PAO_APP_ID,
|
||||||
lang: this.getlang(),
|
lang: mylang,
|
||||||
email: authData.email,
|
email: authData.email,
|
||||||
password: String(hashedPassword),
|
password: String(hashedPassword),
|
||||||
username: authData.username,
|
username: authData.username,
|
||||||
@@ -350,7 +353,7 @@ class User extends VuexModule implements IUserState { // Non occorrono i gette
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Action({ commit: types.USER_SIGNIN })
|
@Action({ commit: types.USER_SIGNIN })
|
||||||
signin (authData: IUserState) {
|
signin (authData: ISignupOptions) {
|
||||||
let call = process.env.MONGODB_HOST + '/users/login'
|
let call = process.env.MONGODB_HOST + '/users/login'
|
||||||
console.log('LOGIN ' + call)
|
console.log('LOGIN ' + call)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
export { duplicate } from './duplicate'
|
export { duplicate } from './duplicate'
|
||||||
export { registered } from './registered'
|
export { registereduser } from './registereduser'
|
||||||
export { complexity } from './complexity'
|
export { registeredemail } from './registeredemail'
|
||||||
|
export { complexity } from './complexity'
|
||||||
|
|||||||
@@ -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)
|
|
||||||
|
|
||||||
}
|
|
||||||
19
src/validation/registeredemail.ts
Normal file
19
src/validation/registeredemail.ts
Normal 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
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
24
src/validation/registereduser.ts
Normal file
24
src/validation/registereduser.ts
Normal 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
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<p>
|
<p>
|
||||||
<!--<img src="../../../assets/quasar-logo-full.svg">-->
|
<!--<img src="../../../assets/quasar-logo-full.svg">-->
|
||||||
<img :src="`../../../assets/`+`${env('LOGO_REG')}`">
|
<img src="../../../assets/{{ logoimg }}">
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ISignupOptions } from '@/model'
|
import { ISignupOptions } from '@/model'
|
||||||
import { required, minLength, email, sameAs } from 'vuelidate/lib/validators'
|
import { required, minLength, email, sameAs } from 'vuelidate/lib/validators'
|
||||||
import { ValidationRuleset } from 'vuelidate'
|
import { ValidationRuleset } from 'vuelidate'
|
||||||
import { complexity, registered } from '@/validation'
|
import { complexity, registereduser, registeredemail } from '@/validation'
|
||||||
|
|
||||||
export type TSignup = { signup: ISignupOptions, validationGroup: string[] }
|
export type TSignup = { signup: ISignupOptions, validationGroup: string[] }
|
||||||
|
|
||||||
@@ -17,11 +17,12 @@ export const validations = {
|
|||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
required,
|
required,
|
||||||
registered
|
registereduser
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
required,
|
required,
|
||||||
email
|
email,
|
||||||
|
registeredemail
|
||||||
},
|
},
|
||||||
terms: {
|
terms: {
|
||||||
required
|
required
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { validations, TSignup } from './signup-validate'
|
|||||||
import { validationMixin } from 'vuelidate'
|
import { validationMixin } from 'vuelidate'
|
||||||
|
|
||||||
import './signup.scss'
|
import './signup.scss'
|
||||||
import { complexity, registered } from '@/validation'
|
|
||||||
|
|
||||||
// import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar'
|
// 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() {
|
get allowSubmit() {
|
||||||
|
|
||||||
let error = this.$v.$error || this.$v.$invalid
|
let error = this.$v.$error || this.$v.$invalid
|
||||||
@@ -88,7 +91,7 @@ export default class Signup extends Vue {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}, */
|
}, */
|
||||||
env() {
|
public env() {
|
||||||
return process.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.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.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')
|
if (!item.maxLength) return this.$t('reg.err.notmore') + ` ${item.$params.maxLength.max} ` + this.$t('reg.err.char')
|
||||||
return ''
|
return ''
|
||||||
@@ -139,7 +143,7 @@ export default class Signup extends Vue {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
public submitOk() {
|
||||||
this.$v.signup.$touch()
|
this.$v.signup.$touch()
|
||||||
|
|
||||||
this.duplicate_email = false
|
this.duplicate_email = false
|
||||||
@@ -167,8 +171,6 @@ export default class Signup extends Vue {
|
|||||||
this.$q.loading.hide()
|
this.$q.loading.hide()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<p>
|
<p>
|
||||||
<!--<img src="../../../assets/quasar-logo-full.svg">-->
|
<!--<img src="../../../assets/quasar-logo-full.svg">-->
|
||||||
<img :src="`../../../assets/`+`${env('LOGO_REG')}`">
|
<img :src="`../../../assets/${logoimg()}`">
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -76,13 +76,15 @@
|
|||||||
:label="$t('reg.terms')"></q-checkbox>
|
:label="$t('reg.terms')"></q-checkbox>
|
||||||
</q-field>
|
</q-field>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<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')}}
|
<div align="center">
|
||||||
|
<q-btn rounded size="lg" color="primary" @click="submitOk" :disable="">{{$t('reg.submit')}}
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user