- 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

@@ -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)