- Downline User

- Not registered if already exists.
- Forgot Password
This commit is contained in:
Paolo Arena
2020-01-30 01:20:23 +01:00
parent 3653b8309c
commit 1956e53d07
24 changed files with 325 additions and 408 deletions

View File

@@ -230,12 +230,6 @@ namespace Actions {
CancelEvent: b.dispatch(CancelEvent)
}
// async function resetpwd(context, paramquery: ICalendarState) {
// }
//
// export const actions = {
// autologin_FromLocalStorage: b.dispatch(autologin_FromLocalStorage)
// }
}
// Module

View File

@@ -37,7 +37,8 @@ export const DefaultUser: IUserFields = {
made_gift: false,
profile: {
img: '',
teleg_id: 0
teleg_id: 0,
saw_zoom_presentation: false,
},
downline: [],
calcstat: DefaultCalc
@@ -114,6 +115,13 @@ namespace Getters {
// }
// }, 'tok')
const VistoZoom = b.read((mystate) => {
if (state.my && state.my.profile) {
return (state.my.profile.saw_zoom_presentation)
}
return false
}, 'VistoZoom')
const isServerError = b.read((mystate) => {
return (state.servercode === tools.ERR_SERVERFETCH)
}, 'isServerError')
@@ -122,6 +130,10 @@ namespace Getters {
return state.servercode
}, 'getServerCode')
const getMsg = b.read((mystate) => {
return state.msg
}, 'getMsg')
const getNameSurnameByUserId = b.read((mystate: IUserState) => (userId: string) => {
const user = UserStore.getters.getUserByUserId(userId)
if (user)
@@ -188,10 +200,12 @@ namespace Getters {
return ''
}
}, 'getImgByUsername')
const getRefLink = b.read((mystate: IUserState) => (): string => {
const getRefLink = b.read((mystate: IUserState) => (username: string): string => {
// console.log('myrec', myrec)
return tools.getUrlSite() + '/signup/' + mystate.my.username
if (username === '')
username = mystate.my.username
return tools.getUrlSite() + '/signup/' + username
}, 'getRefLink')
@@ -214,9 +228,15 @@ namespace Getters {
get isServerError() {
return isServerError()
},
get VistoZoom() {
return VistoZoom()
},
get getServerCode() {
return getServerCode()
},
get getMsg() {
return getMsg()
},
get IsMyFriend() {
return IsMyFriend()
},
@@ -380,6 +400,7 @@ namespace Mutations {
if (mystate.servercode !== tools.ERR_SERVERFETCH) {
mystate.servercode = axerr.getCode()
}
mystate.msg = axerr.getMsg()
console.log('Err catch: (servercode:', axerr.getCode(), axerr.getMsgError(), ')')
} catch (e) {
console.log('Err catch:', axerr)
@@ -435,24 +456,23 @@ namespace Actions {
}
}
async function resetpwd(context, paramquery: IUserState) {
async function resetpwd(context, paramquery) {
const usertosend = {
email: paramquery.my.email,
password: paramquery.my.password,
tokenforgot: paramquery.tokenforgot
}
console.log(usertosend)
const mydata = { ...paramquery }
Mutations.mutations.setServerCode(tools.CALLING)
return bcrypt.hash(mydata.password, bcrypt.genSaltSync(12))
.then((hashedPassword: string) => {
mydata.repeatPassword = ''
mydata.password = String(hashedPassword)
return await Api.SendReq('/updatepwd', 'POST', usertosend, true)
.then((res) => {
return { code: res.data.code, msg: res.data.msg }
})
.catch((error: Types.AxiosError) => {
UserStore.mutations.setErrorCatch(error)
return { code: UserStore.getters.getServerCode, msg: error.getMsgError() }
return Api.SendReq('/updatepwd', 'POST', mydata, true)
.then((res) => {
return { code: res.data.code, msg: res.data.msg }
})
.catch((error: Types.AxiosError) => {
UserStore.mutations.setErrorCatch(error)
return { code: UserStore.getters.getServerCode, msg: error.getMsgError() }
})
})
}
@@ -540,6 +560,16 @@ namespace Actions {
})
}
async function execDbOp(context, paramquery) {
return await Api.SendReq('/users/dbop', 'POST', paramquery)
.then((res) => {
return res
}).catch((error) => {
return false
})
}
async function newsletterload(context, paramquery) {
return await Api.SendReq('/news/load', 'POST', paramquery)
@@ -623,15 +653,15 @@ namespace Actions {
// dispatch('storeUser', authData);
// dispatch('setLogoutTimer', myres.data.expiresIn);
return tools.OK
return { code: tools.OK, msg: '' }
} else {
return tools.ERR_GENERICO
return { code: tools.ERR_GENERICO, msg: '' }
}
})
.catch((error) => {
console.log('Err', error)
UserStore.mutations.setErrorCatch(error)
return UserStore.getters.getServerCode
return { code: UserStore.getters.getServerCode, msg: UserStore.getters.getMsg }
})
})
}
@@ -885,7 +915,6 @@ namespace Actions {
})
}
/*
async function refreshUserInfos(){
let {token, refresh_token} = JWT.fetch();
@@ -913,6 +942,7 @@ namespace Actions {
unsubscribe: b.dispatch(unsubscribe),
importemail: b.dispatch(importemail),
importExtraList: b.dispatch(importExtraList),
execDbOp: b.dispatch(execDbOp),
newsletterload: b.dispatch(newsletterload),
newsletter_setactivate: b.dispatch(newsletter_setactivate),
getDashboard: b.dispatch(getDashboard),

View File

@@ -410,6 +410,7 @@ export const fieldsTable = {
// AddCol({ name: '_id', label_trans: 'reg.id' }),
AddCol({ name: 'ind_order', label_trans: 'reg.ind_order' }),
AddCol({ name: 'date_reg', label_trans: 'reg.date_reg', fieldtype: tools.FieldType.date }),
AddCol({ name: 'date_temp_reg', label_trans: 'reg.date_temp_reg', fieldtype: tools.FieldType.date }),
AddCol({ name: 'username', label_trans: 'reg.username_short' }),
AddCol({ name: 'name', label_trans: 'reg.name' }),
AddCol({ name: 'surname', label_trans: 'reg.surname' }),
@@ -421,12 +422,12 @@ export const fieldsTable = {
AddCol({ name: 'verified_email', label_trans: 'reg.verified_email', fieldtype: tools.FieldType.boolean }),
AddCol({ name: 'profile.saw_zoom_presentation', field: 'profile', subfield: 'saw_zoom_presentation', label_trans: 'reg.saw_zoom_presentation', fieldtype: tools.FieldType.boolean }),
AddCol({ name: 'profile.my_dream', field: 'profile', subfield: 'my_dream', label_trans: 'reg.my_dream' }),
AddCol({ name: 'profile.nationality', field: 'profile', subfield: 'nationality', label_trans: 'reg.nationality', fieldtype: tools.FieldType.nationality }),
AddCol({ name: 'profile.intcode_cell', field: 'profile', subfield: 'intcode_cell', label_trans: 'reg.intcode_cell', fieldtype: tools.FieldType.intcode }),
AddCol({ name: 'profile.nationality', field: 'profile', subfield: 'nationality', label_trans: 'reg.nationality' }),
AddCol({ name: 'profile.intcode_cell', field: 'profile', subfield: 'intcode_cell', label_trans: 'reg.intcode_cell' }),
AddCol({ name: 'profile.iso2_cell', field: 'profile', subfield: 'iso2_cell', label_trans: 'reg.iso2_cell' }),
AddCol({ name: 'profile.cell', field: 'profile', subfield: 'cell', label_trans: 'reg.cell', fieldtype: tools.FieldType.intcode }),
AddCol({ name: 'profile.cell', field: 'profile', subfield: 'cell', label_trans: 'reg.cell' }),
AddCol({ name: 'profile.email_paypal', field: 'profile', subfield: 'email_paypal', label_trans: 'reg.email_paypal' }),
AddCol({ name: 'profile.country_pay', field: 'profile', subfield: 'country_pay', label_trans: 'reg.country_pay', fieldtype: tools.FieldType.nationality }),
AddCol({ name: 'profile.country_pay', field: 'profile', subfield: 'country_pay', label_trans: 'reg.country_pay' }),
AddCol({ name: 'profile.teleg_id', field: 'profile', subfield: 'teleg_id', label_trans: 'reg.teleg_id' }),
AddCol({ name: 'profile.teleg_checkcode', field: 'profile', subfield: 'teleg_checkcode', label_trans: 'reg.teleg_checkcode' }),
AddCol({ name: 'profile.manage_telegram', field: 'profile', subfield: 'manage_telegram', label_trans: 'reg.manage_telegram', fieldtype: tools.FieldType.boolean }),

View File

@@ -10,8 +10,9 @@ export const serv_constants = {
RIS_CODE_USER_EXTRALIST_NOTFOUND: -70,
RIS_CODE_USERNAME_ALREADY_EXIST: -60,
RIS_CODE_EMAIL_ALREADY_EXIST: -50,
RIS_CODE_EMAIL_NOT_SENT: -40,
RIS_CODE_USER_ALREADY_EXIST: -48,
RIS_CODE_EMAIL_NOT_EXIST: -45,
RIS_CODE_EMAIL_NOT_SENT: -40,
RIS_CODE_ERR_UNAUTHORIZED: -30,
RIS_CODE_LOGIN_ERR_GENERIC: -20,
@@ -21,6 +22,8 @@ export const serv_constants = {
RIS_CODE_LOGIN_OK: 1,
RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN: 403,
RIS_CODE_TOKEN_RESETPASSWORD_NOT_FOUND: -23,
RIS_SUBSCRIBED_OK: 1,
RIS_SUBSCRIBED_ALREADYEXIST: 2,
RIS_SUBSCRIBED_ERR: -1,

View File

@@ -1480,15 +1480,14 @@ export const tools = {
},
showNegativeNotif(q: any, msg) {
tools.showNotif(q, msg, { color: 'negative', icon: 'notifications' })
tools.showNotif(q, msg, { color: 'negative', icon: 'notifications' }, 8000)
},
showNeutralNotif(q: any, msg) {
tools.showNotif(q, msg, { color: 'info', icon: 'notifications' })
},
showNotif(q: any, msg, data ?: INotify | null
) {
showNotif(q: any, msg, data ?: INotify | null, time?) {
let myicon = data ? data.icon : 'ion-add'
if (!myicon) {
myicon = 'ion-add'
@@ -1502,7 +1501,7 @@ export const tools = {
icon: myicon,
classes: 'my-notif-class',
color: mycolor,
timeout: 3000
timeout: time || 4000
})
}
,
@@ -2621,18 +2620,20 @@ export const tools = {
}
,
SignUpcheckErrors(mythis, riscode: number) {
SignUpcheckErrors(mythis, riscode: number, msg: string) {
console.log('SignUpcheckErrors', riscode)
let endload = true
if (riscode === serv_constants.RIS_CODE_EMAIL_ALREADY_EXIST) {
tools.showNotif(mythis.$q, mythis.$t('reg.err.duplicate_email'))
} else if (riscode === serv_constants.RIS_CODE_USER_ALREADY_EXIST) {
tools.showNegativeNotif(mythis.$q, mythis.$t('reg.err.user_already_exist'))
} else if (riscode === serv_constants.RIS_CODE_USER_EXTRALIST_NOTFOUND) {
tools.showNegativeNotif(mythis.$q, mythis.$t('reg.err.user_extralist_not_found'))
tools.showNegativeNotif(mythis.$q, mythis.$t('reg.err.user_extralist_not_found') + ' ' + msg)
} else if (riscode === serv_constants.RIS_CODE_USER_NOT_THIS_APORTADOR) {
tools.showNegativeNotif(mythis.$q, mythis.$t('reg.err.user_not_this_aportador'))
tools.showNegativeNotif(mythis.$q, mythis.$t('reg.err.user_not_this_aportador') + ' ' + msg)
} else if (riscode === serv_constants.RIS_CODE_USERNAME_ALREADY_EXIST) {
tools.showNotif(mythis.$q, mythis.$t('reg.err.duplicate_username'))
@@ -3016,6 +3017,10 @@ export const tools = {
return 'https://www.youtube.com/embed/' + this.getvideourl(index, true)
},
getvideobyidyoutube(key) {
return 'https://www.youtube.com/embed/' + key
},
getpath(myvideo) {
return 'statics/video/' + func_tools.getLocale() + '/' + myvideo
},
@@ -3060,27 +3065,41 @@ export const tools = {
},
geticon(langin) {
let lang = langin.toUpperCase()
if (lang === 'IT')
return 'fa-flag-it'
else if (lang === 'ES')
return 'fa-flag-es'
else if (lang === 'US')
return 'fa-flag-us'
else if ((lang === 'GB') || (lang === 'UK'))
return 'fa-flag-gb'
else if (lang === 'DE')
return 'fa-flag-de'
else if (lang === 'SI')
return 'fa-flag-si'
else if (lang === 'CH')
return 'fa-flag-ch'
else if (lang === 'PE')
return 'fa-flag-pe'
else if (lang === 'HR')
return 'fa-flag-hr'
if (langin === '')
return ''
try {
let lang = langin.toUpperCase()
if (lang === 'IT')
return 'fa-flag-it'
else if (lang === 'ES')
return 'fa-flag-es'
else if (lang === 'US')
return 'fa-flag-us'
else if ((lang === 'GB') || (lang === 'UK'))
return 'fa-flag-gb'
else if (lang === 'DE')
return 'fa-flag-de'
else if (lang === 'FR')
return 'fa-flag-fr'
else if (lang === 'SI')
return 'fa-flag-si'
else if (lang === 'CH')
return 'fa-flag-ch'
else if (lang === 'CM')
return 'fa-flag-cm'
else if (lang === 'CO')
return 'fa-flag-co'
else if (lang === 'PE')
return 'fa-flag-pe'
else if (lang === 'SM')
return 'fa-flag-sm'
else if (lang === 'HR')
return 'fa-flag-hr'
return ''
return ''
}catch (e) {
return ''
}
},
removespaces(mystr) {
@@ -3094,7 +3113,7 @@ export const tools = {
},
getNationsByNationality(nat) {
getNationsByNationality(nat, code) {
if (nat === 'IT') {
return 'Italy'
} else if (nat === 'SI') {
@@ -3103,6 +3122,8 @@ export const tools = {
return 'Spain'
} else if (nat === 'DE') {
return 'Germany'
} else if (nat === 'FR') {
return 'France'
} else if (nat === 'US') {
return 'United States'
} else if (nat === 'CA') {
@@ -3117,10 +3138,16 @@ export const tools = {
return 'Hungary'
} else if (nat === 'CH') {
return 'Switzerland'
} else if (nat === 'CM') {
return 'Cameroon'
} else if (nat === 'CO') {
return 'Colombia'
} else if (nat === 'PE') {
return 'Peru'
} else if (nat === 'PL') {
return 'Poland'
} else if (nat === 'SM') {
return 'San Marino'
} else if (nat === 'PT') {
return 'Portugal'
} else if (nat === 'UK') {