Some refactoring
This commit is contained in:
parent
7baa5097f9
commit
77c5e7117b
|
@ -1,7 +1,7 @@
|
|||
version: '3'
|
||||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
image: postgres:latest
|
||||
restart: 'no'
|
||||
environment:
|
||||
POSTGRES_USER: prisma
|
||||
|
@ -12,7 +12,7 @@ services:
|
|||
- '5432:5432'
|
||||
|
||||
pgadmin:
|
||||
image: dpage/pgadmin4
|
||||
image: dpage/pgadmin4:latest
|
||||
restart: 'no'
|
||||
environment:
|
||||
PGADMIN_DEFAULT_EMAIL: 'admin@pg.com'
|
||||
|
|
|
@ -21,9 +21,8 @@ class ResetToken {
|
|||
throw new Error('Apenas estudantes podem utilizar tokens')
|
||||
|
||||
const token = uuid()
|
||||
const expiration = moment(new Date())
|
||||
.add(3, 'days')
|
||||
.toDate()
|
||||
// TODO: replace momentJS
|
||||
const expiration = moment(new Date()).add(3, 'days').toDate()
|
||||
|
||||
console.log(expiration)
|
||||
|
||||
|
@ -84,9 +83,11 @@ class ResetToken {
|
|||
throw new Error('Token inválido, já usado ou expirado')
|
||||
}
|
||||
|
||||
const user = await prisma.resetToken.findOne({
|
||||
where: { id: resetToken.id }
|
||||
}).user()
|
||||
const user = await prisma.resetToken
|
||||
.findOne({
|
||||
where: { id: resetToken.id }
|
||||
})
|
||||
.user()
|
||||
|
||||
await replacePassword(user.sAMAccountName, newPassword)
|
||||
|
||||
|
|
|
@ -82,8 +82,11 @@ const Query = {
|
|||
|
||||
async stats() {
|
||||
return {
|
||||
//TODO: count
|
||||
tokenCountTotal: prisma.resetToken.count(),
|
||||
tokenCountUsed: 0,
|
||||
tokenCountUsed: prisma.resetToken.count({
|
||||
where: { NOT: { usedAt: null } }
|
||||
}),
|
||||
tokenCountExpired: 0,
|
||||
tokenCountNotUsed: 0
|
||||
}
|
||||
|
@ -102,10 +105,10 @@ const Query = {
|
|||
})
|
||||
},
|
||||
userPresence: async (_, { search }) => {
|
||||
// if (!search) {
|
||||
// await updateDBWithOnlineDevices()
|
||||
// search = ''
|
||||
// }
|
||||
if (!search) {
|
||||
await updateDBWithOnlineDevices()
|
||||
search = ''
|
||||
}
|
||||
|
||||
const usersWithWifiDevices = await prisma.user.findMany({
|
||||
include: { WifiDevice: true }
|
||||
|
@ -130,8 +133,6 @@ const Query = {
|
|||
)
|
||||
}))
|
||||
|
||||
console.dir(userPresences)
|
||||
|
||||
const sortedUserPresences = userPresences.sort((a, b) =>
|
||||
a.wifiDevices[0].lastSeen > b.wifiDevices[0].lastSeen ? -1 : 1
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user