mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-17 02:29:10 +00:00
v2: init -- UI is nuked from orbit, major app restructuring
This commit is contained in:
parent
c6f5b55c1c
commit
b8da886601
108 changed files with 6717 additions and 17430 deletions
42
services/sessions.js
Normal file
42
services/sessions.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
const Service = require('./Service')
|
||||
|
||||
class SessionsService extends Service {
|
||||
constructor (ctx) {
|
||||
super(ctx)
|
||||
this.Session = ctx.M.Session
|
||||
}
|
||||
|
||||
async get (id, {rolling}) {
|
||||
const user = await this.Session.findOne({ where: { id } })
|
||||
|
||||
if (user === null) {
|
||||
return null
|
||||
}
|
||||
|
||||
return user.data
|
||||
}
|
||||
|
||||
async set (id, data, {maxAge, rolling, changed}) {
|
||||
let session = await this.Session.findOne({ where: { id } })
|
||||
if (session === null) {
|
||||
session = this.Session.build({ id })
|
||||
}
|
||||
|
||||
console.log(maxAge)
|
||||
|
||||
session.data = data
|
||||
session.maxAge = maxAge
|
||||
|
||||
return session.save()
|
||||
}
|
||||
|
||||
async destroy (id) {
|
||||
const sess = await this.Session.findOne({ where: { id } })
|
||||
|
||||
if (sess != null) {
|
||||
return sess.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SessionsService
|
Loading…
Add table
Add a link
Reference in a new issue