From f5b73414b1d3b5a4e1ab1ba720da414444b66d6b Mon Sep 17 00:00:00 2001 From: paolo Date: Mon, 12 Nov 2018 18:08:06 +0100 Subject: [PATCH] Bottone Registrati: manca getlang che non funziona.... --- .env | 2 +- src/common/message.ts | 5 +++-- src/config.ts | 2 +- src/i18n.js | 2 ++ src/model/payload/index.ts | 6 +++--- src/model/payload/payload-mapper.ts | 5 ----- src/model/payload/payload-message.ts | 6 +++--- src/store/modules/user.ts | 15 ++++++++------ src/validation/index.ts | 5 +++-- src/validation/registered.ts | 22 --------------------- src/validation/registeredemail.ts | 19 ++++++++++++++++++ src/validation/registereduser.ts | 24 +++++++++++++++++++++++ src/views/login/signin.vue | 2 +- src/views/login/signup/signup-validate.ts | 7 ++++--- src/views/login/signup/signup.ts | 12 +++++++----- src/views/login/signup/signup.vue | 12 +++++++----- 16 files changed, 87 insertions(+), 59 deletions(-) delete mode 100644 src/validation/registered.ts create mode 100644 src/validation/registeredemail.ts create mode 100644 src/validation/registereduser.ts diff --git a/.env b/.env index 8ef93e1..79519a9 100644 --- a/.env +++ b/.env @@ -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' diff --git a/src/common/message.ts b/src/common/message.ts index 7be3885..f5056a4 100644 --- a/src/common/message.ts +++ b/src/common/message.ts @@ -3,5 +3,6 @@ export const PayloadMessageTypes = { info: 'Info', failure: 'Failure', success: 'Success', - warning: 'Warning' -} \ No newline at end of file + warning: 'Warning', + statusfound: 200 +} diff --git a/src/config.ts b/src/config.ts index a07c2a6..5540b48 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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 = { diff --git a/src/i18n.js b/src/i18n.js index 7977129..f08386a 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -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.', diff --git a/src/model/payload/index.ts b/src/model/payload/index.ts index a4eea21..50391bf 100644 --- a/src/model/payload/index.ts +++ b/src/model/payload/index.ts @@ -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' diff --git a/src/model/payload/payload-mapper.ts b/src/model/payload/payload-mapper.ts index 07bb048..9a99b30 100644 --- a/src/model/payload/payload-mapper.ts +++ b/src/model/payload/payload-mapper.ts @@ -9,7 +9,6 @@ export class PayloadMapper { private fromError(o: Error): IPayload { return { - // @ts-ignore data: null, message: { messageTypeId: PayloadMessageTypes.error, @@ -21,7 +20,6 @@ export class PayloadMapper { private fromAxiosError(o: AxiosError): IPayload { - // @ts-ignore let data: T = null if (o.response && isAxiosResponse(o.response)) @@ -39,7 +37,6 @@ export class PayloadMapper { private fromAxiosResponse(o: AxiosResponse): IPayload { - // @ts-ignore let value: IPayload = null if (isPayload(o.data)) @@ -49,7 +46,6 @@ export class PayloadMapper { data: o.data, message: { messageTypeId: PayloadMessageTypes.success, - // @ts-ignore text: null } } @@ -67,7 +63,6 @@ export class PayloadMapper { if (isAxiosResponse(o)) return this.fromAxiosResponse(o) - // @ts-ignore return null } } diff --git a/src/model/payload/payload-message.ts b/src/model/payload/payload-message.ts index d73b4c3..81ae4a9 100644 --- a/src/model/payload/payload-message.ts +++ b/src/model/payload/payload-message.ts @@ -1,6 +1,6 @@ export interface IPayloadMessage { - text: string; - title?: string; - messageTypeId: string; + text: string + title?: string + messageTypeId: string } \ No newline at end of file diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 09eb449..29daed4 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -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) diff --git a/src/validation/index.ts b/src/validation/index.ts index 86fd7b3..659e722 100644 --- a/src/validation/index.ts +++ b/src/validation/index.ts @@ -1,3 +1,4 @@ export { duplicate } from './duplicate' -export { registered } from './registered' -export { complexity } from './complexity' \ No newline at end of file +export { registereduser } from './registereduser' +export { registeredemail } from './registeredemail' +export { complexity } from './complexity' diff --git a/src/validation/registered.ts b/src/validation/registered.ts deleted file mode 100644 index 4e569b2..0000000 --- a/src/validation/registered.ts +++ /dev/null @@ -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 = res.data - return payload.message.messageTypeId !== PayloadMessageTypes.failure - } - - return Axios.get(VALIDATE_USER_URL, config) - .then(onSuccess) - -} \ No newline at end of file diff --git a/src/validation/registeredemail.ts b/src/validation/registeredemail.ts new file mode 100644 index 0000000..12b4887 --- /dev/null +++ b/src/validation/registeredemail.ts @@ -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 + }) + +} diff --git a/src/validation/registereduser.ts b/src/validation/registereduser.ts new file mode 100644 index 0000000..379843f --- /dev/null +++ b/src/validation/registereduser.ts @@ -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 + }) + +} diff --git a/src/views/login/signin.vue b/src/views/login/signin.vue index b042860..0adc1db 100644 --- a/src/views/login/signin.vue +++ b/src/views/login/signin.vue @@ -4,7 +4,7 @@

- +

diff --git a/src/views/login/signup/signup-validate.ts b/src/views/login/signup/signup-validate.ts index 232f25a..0024be5 100644 --- a/src/views/login/signup/signup-validate.ts +++ b/src/views/login/signup/signup-validate.ts @@ -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 diff --git a/src/views/login/signup/signup.ts b/src/views/login/signup/signup.ts index 0c79139..194b48d 100644 --- a/src/views/login/signup/signup.ts +++ b/src/views/login/signup/signup.ts @@ -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() }) - - // ... } } diff --git a/src/views/login/signup/signup.vue b/src/views/login/signup/signup.vue index c5b6e0f..2948cce 100644 --- a/src/views/login/signup/signup.vue +++ b/src/views/login/signup/signup.vue @@ -3,7 +3,7 @@

- +

@@ -76,13 +76,15 @@ :label="$t('reg.terms')"> - -
+ {{$t('reg.submit')}} + +