chore: server code formatting
This commit is contained in:
parent
aedabcbdee
commit
68517170e2
234 changed files with 9824 additions and 6195 deletions
|
|
@ -1,11 +1,11 @@
|
|||
const db = require('./db')
|
||||
|
||||
function getSessions () {
|
||||
function getSessions() {
|
||||
const sql = `SELECT * FROM user_sessions ORDER BY sess -> 'user' ->> 'username'`
|
||||
return db.any(sql)
|
||||
}
|
||||
|
||||
function getLastSessionPerUser () {
|
||||
function getLastSessionPerUser() {
|
||||
const sql = `SELECT b.username, a.user_agent, a.ip_address, a.last_used, b.role FROM (
|
||||
SELECT sess -> 'user' ->> 'username' AS username,
|
||||
sess ->> 'ua' AS user_agent,
|
||||
|
|
@ -19,24 +19,31 @@ function getLastSessionPerUser () {
|
|||
return db.any(sql)
|
||||
}
|
||||
|
||||
function getSessionsByUsername (username) {
|
||||
function getSessionsByUsername(username) {
|
||||
const sql = `SELECT * FROM user_sessions WHERE sess -> 'user' ->> 'username'=$1`
|
||||
return db.any(sql, [username])
|
||||
}
|
||||
|
||||
function getSessionById (sessionID) {
|
||||
function getSessionById(sessionID) {
|
||||
const sql = `SELECT * FROM user_sessions WHERE sid=$1`
|
||||
return db.any(sql, [sessionID])
|
||||
}
|
||||
|
||||
function deleteSessionsByUsername (username) {
|
||||
function deleteSessionsByUsername(username) {
|
||||
const sql = `DELETE FROM user_sessions WHERE sess -> 'user' ->> 'username'=$1`
|
||||
return db.none(sql, [username])
|
||||
}
|
||||
|
||||
function deleteSessionById (sessionID) {
|
||||
function deleteSessionById(sessionID) {
|
||||
const sql = `DELETE FROM user_sessions WHERE sid=$1`
|
||||
return db.none(sql, [sessionID])
|
||||
}
|
||||
|
||||
module.exports = { getSessions, getLastSessionPerUser, getSessionsByUsername, getSessionById, deleteSessionsByUsername, deleteSessionById }
|
||||
module.exports = {
|
||||
getSessions,
|
||||
getLastSessionPerUser,
|
||||
getSessionsByUsername,
|
||||
getSessionById,
|
||||
deleteSessionsByUsername,
|
||||
deleteSessionById,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue