- Modified privacywrite query with graphLookup:

$graphLookup: {
        from: "projects",
        startWith: "$id_main_project",
        connectFromField: "id_main_project",
        connectToField: "_id",
        as: "ris",
        restrictSearchWithMatch: { $or: [{ privacyread: server_constants.Privacy.all }, { userId: userId }] }
      }
    },
    { $match: { "ris.privacyread": { $exists: true } } },
This commit is contained in:
Paolo Arena
2019-04-13 03:04:40 +02:00
parent 7b1e24c407
commit 3c05d2d9c7
10 changed files with 94 additions and 95 deletions

View File

@@ -17,7 +17,7 @@ export function getLinkByTableName(nametable) {
}
}
export const LIST_START = '0'
export const LIST_START = null
export const DB = {
CMD_SYNC: 'sync',
@@ -432,5 +432,5 @@ export function table_DeleteRecord(nametable, myobjtrov, id) {
// 3) Delete from the Server (call)
Sync_DeleteItem(nametable, myobjtrov, id)
}

View File

@@ -102,7 +102,7 @@ namespace Getters {
const listaprojects = b.read((state: IProjectsState) => (): IMenuList[] => {
if (state.projects) {
console.log('state.projects', state.projects)
// console.log('state.projects', state.projects)
const listaproj = tools.mapSort(state.projects.filter((proj) => proj.id_parent === process.env.PROJECT_ID_MAIN))
const myarr: IMenuList[] = []
for (const proj of listaproj) {
@@ -212,9 +212,9 @@ namespace Actions {
}
}
if (UserStore.state.userId === '') {
return false // Login not made
}
// if (UserStore.state.userId === '') {
// return false // Login not made
// }
console.log('dbLoad', nametable, checkPending, 'userid=', UserStore.state.userId)

View File

@@ -510,13 +510,15 @@ namespace Actions {
// this.$router.push('/signin')
}
async function setGlobal(loggedWithNetwork: boolean) {
async function setGlobal(isLogged: boolean) {
state.isLogged = true
console.log('state.isLogged')
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
if (isLogged) {
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
GlobalStore.actions.checkUpdates()
GlobalStore.actions.checkUpdates()
}
await GlobalStore.actions.loadAfterLogin()
.then(() => {
@@ -530,36 +532,37 @@ namespace Actions {
console.log('*** autologin_FromLocalStorage ***')
// INIT
let isLogged = false
UserStore.state.lang = tools.getItemLS(tools.localStorage.lang)
const token = localStorage.getItem(tools.localStorage.token)
if (!token) {
return false
if (token) {
const expirationDateStr = localStorage.getItem(tools.localStorage.expirationDate)
const expirationDate = new Date(String(expirationDateStr))
const now = tools.getDateNow()
if (now < expirationDate) {
const userId = String(localStorage.getItem(tools.localStorage.userId))
const username = String(localStorage.getItem(tools.localStorage.username))
const verified_email = localStorage.getItem(tools.localStorage.verified_email) === 'true'
GlobalStore.state.wasAlreadySubOnDb = localStorage.getItem(tools.localStorage.wasAlreadySubOnDb) === 'true'
console.log('************* autologin userId', userId)
UserStore.mutations.setAuth(token)
Mutations.mutations.authUser({
userId,
username,
verified_email
})
isLogged = true
}
}
const expirationDateStr = localStorage.getItem(tools.localStorage.expirationDate)
const expirationDate = new Date(String(expirationDateStr))
const now = tools.getDateNow()
if (now >= expirationDate) {
console.log('!!! Login Expired')
return false
}
const userId = String(localStorage.getItem(tools.localStorage.userId))
const username = String(localStorage.getItem(tools.localStorage.username))
const verified_email = localStorage.getItem(tools.localStorage.verified_email) === 'true'
GlobalStore.state.wasAlreadySubOnDb = localStorage.getItem(tools.localStorage.wasAlreadySubOnDb) === 'true'
console.log('************* autologin userId', userId)
UserStore.mutations.setAuth(token)
Mutations.mutations.authUser({
userId,
username,
verified_email
})
await setGlobal(false)
await setGlobal(isLogged)
console.log('autologin userId STATE ', state.userId)