fix Registrazione data

fix linkref
fix controllo login
fix pagination CGridTableRec
This commit is contained in:
Paolo Arena
2020-01-20 01:50:21 +01:00
parent 6541a3a84e
commit 5153c143dd
33 changed files with 540 additions and 415 deletions

View File

@@ -613,12 +613,20 @@ namespace Actions {
}
async function loadAfterLogin(context) {
// console.log('loadAfterLogin')
console.log('loadAfterLogin')
actions.clearDataAfterLoginOnlyIfActiveConnection()
await Actions.actions.loadSite()
let isok = false
if (!await Actions.actions.loadSite()) {
this.$router.push('/signin')
} else {
isok = true
}
state.arrConfig = await globalroutines(null, 'readall', 'config', null)
return isok
}
async function saveCfgServerKey(context, dataval: ICfgServer) {
@@ -806,21 +814,34 @@ namespace Actions {
GlobalStore.state.mypage = (res.data.mypage) ? [...res.data.mypage] : []
}
console.log('res.data.myuser', res.data.myuser)
if (res.data.myuser) {
UserStore.mutations.authUser(res.data.myuser)
UserStore.mutations.updateLocalStorage(res.data.myuser)
} else {
// User not exist !!
}
const islogged = localStorage.getItem(tools.localStorage.username)
console.log('islogged', islogged)
CalendarStore.state.editable = UserStore.state.isAdmin || UserStore.state.isManager
if (res.data.myuser === null && UserStore.state.isLogged) {
// Fai Logout
UserStore.actions.logout()
GlobalStore.state.RightDrawerOpen = true
if (res.data.myuser === null) {
if (islogged) {
// Fai Logout
console.log('Fai Logout', 'islogged', islogged)
UserStore.actions.logout()
GlobalStore.state.RightDrawerOpen = true
return false
}
}
}
return true
})
.catch((error) => {
console.log('error dbLoad', error)
@@ -858,6 +879,7 @@ namespace Actions {
component: () => import('@/root/mypage/mypage.vue'),
inmenu: page.inmenu,
infooter: page.infooter,
onlyif_logged: page.onlyif_logged,
level_child: page.l_child,
level_parent: page.l_par,
})

View File

@@ -96,7 +96,7 @@ namespace Actions {
return await Api.SendReq(`/sendmsg/${username}/${lastdataread}/${process.env.APP_ID}`, 'GET', null)
.then((res) => {
console.log('res', res)
// console.log('res', res)
if (res.status === 200) {
setMsg(res.data.arrmsg, username)
return true
@@ -130,7 +130,7 @@ namespace Actions {
return await Api.SendReq('/sendmsg', 'POST', data)
.then((res) => {
console.log('res', res)
// console.log('res', res)
if (res.status === 200) {
if (res.data.code === serv_constants.RIS_CODE_OK) {
data._id = res.data.id

View File

@@ -1,5 +1,5 @@
import Api from '@api'
import { ISignupOptions, ISigninOptions, IUserState, IUserFields, IUserProfile } from 'model'
import { ISignupOptions, ISigninOptions, IUserState, IUserFields, IUserProfile, ICalcStat } from 'model'
import { ILinkReg, IResult, IIdToken, IToken } from 'model/other'
import { storeBuilder } from './Store/Store'
import router from '@router'
@@ -20,6 +20,11 @@ import { shared_consts } from '../../common/shared_vuejs'
const bcrypt = require('bcryptjs')
export const DefaultCalc: ICalcStat = {
numinvitati: 0,
numinvitati_attivi: 0,
}
export const DefaultUser: IUserFields = {
_id: '',
email: '',
@@ -34,6 +39,7 @@ export const DefaultUser: IUserFields = {
img: ''
},
downline: [],
calcstat: DefaultCalc
}
export const DefaultProfile: IUserProfile = {
@@ -48,7 +54,9 @@ export const DefaultProfile: IUserProfile = {
username_telegram: '',
teleg_id: 0,
teleg_checkcode: 0,
my_dream: '',
manage_telegram: false,
saw_zoom_presentation: false,
paymenttypes: []
}
@@ -187,7 +195,7 @@ namespace Getters {
}, 'getRefLink')
const isVerificato = b.read((mystate: IUserState) => {
const teleg_ok = mystate.my.profile.teleg_id > 0
const teleg_ok = mystate.my.profile.teleg_id > 0 && mystate.my.verified_email
return teleg_ok
}, 'isVerificato')
@@ -352,19 +360,17 @@ namespace Mutations {
}
function clearAuthData(mystate: IUserState) {
mystate.my._id = ''
mystate.my.username = ''
mystate.my.name = ''
mystate.my.surname = ''
resetArrToken(mystate.my.tokens)
mystate.my.verified_email = false
mystate.my.made_gift = false
mystate.my = DefaultUser
// resetArrToken(mystate.my.tokens)
mystate.categorySel = 'personal'
mystate.servercode = 0
mystate.resStatus = 0
mystate.isLogged = false
mystate.x_auth_token = ''
return true
}
function setErrorCatch(mystate: IUserState, axerr: Types.AxiosError) {
@@ -449,10 +455,10 @@ namespace Actions {
}
async function requestpwd(context, paramquery: IUserState) {
async function requestpwd(context, paramquery) {
const usertosend = {
email: paramquery.my.email
email: paramquery.email
}
console.log(usertosend)
@@ -536,7 +542,7 @@ namespace Actions {
return await Api.SendReq('/news/load', 'POST', paramquery)
.then((res) => {
console.log('res', res)
// console.log('res', res)
return res.data
}).catch((error) => {
return null
@@ -547,7 +553,7 @@ namespace Actions {
return await Api.SendReq('/news/setactivate', 'POST', paramquery)
.then((res) => {
console.log('res', res)
// console.log('res', res)
return res.data
}).catch((error) => {
return null
@@ -750,7 +756,7 @@ namespace Actions {
.then((res) => {
console.log(res)
}).then(() => {
Mutations.mutations.clearAuthData()
return Mutations.mutations.clearAuthData()
}).catch((error) => {
UserStore.mutations.setErrorCatch(error)
return UserStore.getters.getServerCode
@@ -762,7 +768,7 @@ namespace Actions {
}
async function setGlobal(isLogged: boolean) {
console.log('setGlobal')
console.log('setGlobal', isLogged)
try {
// state.isLogged = true
if (isLogged) {
@@ -774,9 +780,9 @@ namespace Actions {
GlobalStore.actions.checkUpdates()
}
const p3 = await GlobalStore.actions.loadAfterLogin()
const isok = await GlobalStore.actions.loadAfterLogin()
state.isLogged = isLogged
state.isLogged = isok && isLogged
if (static_data.functionality.ENABLE_TODOS_LOADING)
await Todos.actions.dbLoad({ checkPending: true })
@@ -830,7 +836,7 @@ namespace Actions {
GlobalStore.state.wasAlreadySubOnDb = localStorage.getItem(tools.localStorage.wasAlreadySubOnDb) === 'true'
// console.log('************* autologin _id', _id)
console.log('************* autologin _id', _id)
UserStore.mutations.setAuth(token)

View File

@@ -84,6 +84,7 @@ export const colmypage = [
AddCol({ name: 'keywords', label_trans: 'pages.keywords' }),
AddCol({ name: 'description', label_trans: 'pages.description' }),
AddCol({ name: 'heightimg', label_trans: 'pages.heightimg', fieldtype: tools.FieldType.number }),
AddCol({ name: 'onlyif_logged', label_trans: 'pages.onlyif_logged', fieldtype: tools.FieldType.boolean }),
AddCol({ name: 'imgback', label_trans: 'pages.imgback', fieldtype: tools.FieldType.string }),
AddCol({ name: 'content', label_trans: 'pages.content', fieldtype: tools.FieldType.html }),
AddCol({ name: 'active', label_trans: 'pages.active', fieldtype: tools.FieldType.boolean }),
@@ -402,6 +403,8 @@ export const fieldsTable = {
AddCol({ name: 'aportador_solidario_nome_completo', label_trans: 'reg.aportador_solidario_nome_completo' }),
AddCol({ name: 'aportador_solidario', label_trans: 'reg.aportador_solidario' }),
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.iso2_cell', field: 'profile', subfield: 'iso2_cell', label_trans: 'reg.iso2_cell' }),
@@ -429,6 +432,7 @@ export const fieldsTable = {
AddCol({ name: 'name_complete', label_trans: 'reg.name_complete' }),
AddCol({ name: 'name', label_trans: 'reg.name' }),
AddCol({ name: 'surname', label_trans: 'reg.surname' }),
AddCol({ name: 'saw_zoom_presentation', label_trans: 'reg.saw_zoom_presentation', fieldtype: tools.FieldType.boolean }),
AddCol({ name: 'num_invitati', label_trans: 'reg.num_invitati', fieldtype: tools.FieldType.number }),
AddCol({ name: 'is_in_whatsapp', label_trans: 'reg.is_in_whatsapp', fieldtype: tools.FieldType.boolean }),
AddCol({ name: 'is_in_telegram', label_trans: 'reg.is_in_telegram', fieldtype: tools.FieldType.boolean }),

View File

@@ -1,6 +1,7 @@
export {storeBuilder} from './Store/Store'
export {default as GlobalStore} from './GlobalStore'
export {default as UserStore} from './UserStore'
export {default as NotevoleStore} from './NotevoleStore'
export {default as MessageStore} from './MessageStore'
export {default as Todos} from './Todos'
export {default as Projects} from './Projects'

View File

@@ -6,10 +6,12 @@ export const serv_constants = {
RIS_CODE_EMAIL_ALREADY_VERIFIED: -5,
RIS_CODE_EMAIL_VERIFIED: 1,
RIS_CODE_USER_NOT_THIS_APORTADOR: -75,
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_EMAIL_NOT_EXIST: -45,
RIS_CODE_ERR_UNAUTHORIZED: -30,
RIS_CODE_LOGIN_ERR_GENERIC: -20,

View File

@@ -149,6 +149,7 @@ export const tools = {
image: 2048,
nationality: 4096,
intcode: 5000,
multioption: 6000,
},
FieldTypeArr: [
@@ -1393,6 +1394,11 @@ export const tools = {
let visu = ((elem.onlyAdmin && UserStore.state.isAdmin) || (elem.onlyManager && UserStore.state.isManager)
|| ((!elem.onlyAdmin) && (!elem.onlyManager))) && elem.active
if (!tools.isLoggedToSystem()) {
if (elem.onlyif_logged)
visu = false
}
if (elem.meta && elem.meta.requiresAuth) {
visu = visu && tools.isLoggedToSystem()
}
@@ -1455,11 +1461,11 @@ export const tools = {
cancel: true,
persistent: false
}).onOk(() => {
console.log('OK')
// console.log('OK')
tools.executefunc(myself, table, funcok, par)
return true
}).onCancel(() => {
console.log('CANCEL')
// console.log('CANCEL')
tools.executefunc(myself, table, funccancel, par)
return false
})
@@ -1969,6 +1975,21 @@ export const tools = {
}
,
firstchars_onedot(value, numchars = 200) {
if (!value) {
return ''
}
try {
let mycar = value.substring(0, numchars)
if (value.length > numchars)
mycar += '.'
return mycar
} catch (e) {
return value
}
}
,
getDateNow() {
const mydate = new Date()
return mydate
@@ -2524,9 +2545,9 @@ export const tools = {
// console.log('loginInCorso')
let msg = mythis.$t('login.incorso')
if (process.env.DEBUG) {
msg += ' ' + process.env.MONGODB_HOST
}
// if (process.env.DEBUG) {
// msg += ' ' + process.env.MONGODB_HOST
// }
mythis.$q.loading.show({ message: msg })
}
,
@@ -2596,6 +2617,9 @@ export const tools = {
} else if (riscode === serv_constants.RIS_CODE_USER_EXTRALIST_NOTFOUND) {
tools.showNegativeNotif(mythis.$q, mythis.$t('reg.err.user_extralist_not_found'))
} else if (riscode === serv_constants.RIS_CODE_USER_NOT_THIS_APORTADOR) {
tools.showNegativeNotif(mythis.$q, mythis.$t('reg.err.user_not_this_aportador'))
} else if (riscode === serv_constants.RIS_CODE_USERNAME_ALREADY_EXIST) {
tools.showNotif(mythis.$q, mythis.$t('reg.err.duplicate_username'))
@@ -2607,7 +2631,7 @@ export const tools = {
} else if (riscode === tools.OK) {
mythis.$router.push('/signin')
tools.showNotif(mythis.$q, mythis.$t('components.authentication.email_verification.link_sent'), {
color: 'info',
color: 'green',
textColor: 'black'
})
} else {
@@ -2655,7 +2679,7 @@ export const tools = {
}
,
ActionRecTable(mythis, action, table, id, item, askaction) {
console.log('ActionRecTable', id)
// console.log('ActionRecTable', id)
return tools.askConfirm(mythis.$q, 'Action', translate(askaction) + '?', translate('dialog.yes'), translate('dialog.no'), mythis, table, action, 0, {
param1: id,
param2: item
@@ -2722,7 +2746,7 @@ export const tools = {
},
getheightbywidth(mythis, mywidth, myheight, maxwidth) {
console.log('getheightbywidth')
// console.log('getheightbywidth')
const myw = this.getwidthscale(mythis, mywidth, maxwidth)
return myw * (myheight / mywidth)
},