From 93302cb667821821040a2475b7477586e7182bb7 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Jul 2021 23:30:14 +0100 Subject: [PATCH] Linting. --- packages/auth/src/middleware/passport/google.js | 11 +++++++---- packages/auth/src/middleware/passport/local.js | 11 +++++++---- packages/auth/src/security/sessions.js | 6 +++--- packages/worker/src/api/controllers/admin/sessions.js | 10 +++++++--- packages/worker/src/api/routes/admin/sessions.js | 2 +- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/packages/auth/src/middleware/passport/google.js b/packages/auth/src/middleware/passport/google.js index ab3ae0bb1a..b357eb4903 100644 --- a/packages/auth/src/middleware/passport/google.js +++ b/packages/auth/src/middleware/passport/google.js @@ -64,10 +64,13 @@ async function authenticate(token, tokenSecret, profile, done) { const sessionId = newid() await createASession(dbUser._id, sessionId) - dbUser.token = jwt.sign({ - userId: dbUser._id, - sessionId, - }, env.JWT_SECRET) + dbUser.token = jwt.sign( + { + userId: dbUser._id, + sessionId, + }, + env.JWT_SECRET + ) return done(null, dbUser) } diff --git a/packages/auth/src/middleware/passport/local.js b/packages/auth/src/middleware/passport/local.js index a3968f9da6..90303cb95f 100644 --- a/packages/auth/src/middleware/passport/local.js +++ b/packages/auth/src/middleware/passport/local.js @@ -36,10 +36,13 @@ exports.authenticate = async function (email, password, done) { const sessionId = newid() await createASession(dbUser._id, sessionId) - dbUser.token = jwt.sign({ - userId: dbUser._id, - sessionId, - }, env.JWT_SECRET) + dbUser.token = jwt.sign( + { + userId: dbUser._id, + sessionId, + }, + env.JWT_SECRET + ) // Remove users password in payload delete dbUser.password diff --git a/packages/auth/src/security/sessions.js b/packages/auth/src/security/sessions.js index 353b53871a..4051df7123 100644 --- a/packages/auth/src/security/sessions.js +++ b/packages/auth/src/security/sessions.js @@ -15,8 +15,8 @@ function makeSessionID(userId, sessionId) { exports.createASession = async (userId, sessionId) => { const client = await redis.getSessionClient() const session = { - createdAt: (new Date()).toISOString(), - lastAccessedAt: (new Date()).toISOString(), + createdAt: new Date().toISOString(), + lastAccessedAt: new Date().toISOString(), sessionId, userId, } @@ -41,7 +41,7 @@ exports.invalidateSessions = async (userId, sessionId = null) => { exports.updateSessionTTL = async session => { const client = await redis.getSessionClient() const key = makeSessionID(session.userId, session.sessionId) - session.lastAccessedAt = (new Date()).toISOString() + session.lastAccessedAt = new Date().toISOString() await client.store(key, session, EXPIRY_SECONDS) } diff --git a/packages/worker/src/api/controllers/admin/sessions.js b/packages/worker/src/api/controllers/admin/sessions.js index ce6ccf47e2..170e97d690 100644 --- a/packages/worker/src/api/controllers/admin/sessions.js +++ b/packages/worker/src/api/controllers/admin/sessions.js @@ -1,4 +1,8 @@ -const { getAllSessions, getUserSessions, invalidateSessions } = require("@budibase/auth/sessions") +const { + getAllSessions, + getUserSessions, + invalidateSessions, +} = require("@budibase/auth/sessions") exports.fetch = async ctx => { ctx.body = await getAllSessions() @@ -14,7 +18,7 @@ exports.invalidateUser = async ctx => { const { userId } = ctx.params await invalidateSessions(userId) ctx.body = { - message: "User sessions invalidated" + message: "User sessions invalidated", } } @@ -28,6 +32,6 @@ exports.invalidateSession = async ctx => { const { sessionId } = ctx.params await invalidateSessions(userId, sessionId) ctx.body = { - message: "Session invalidated successfully." + message: "Session invalidated successfully.", } } diff --git a/packages/worker/src/api/routes/admin/sessions.js b/packages/worker/src/api/routes/admin/sessions.js index f7661e2b49..9cf5f58f8b 100644 --- a/packages/worker/src/api/routes/admin/sessions.js +++ b/packages/worker/src/api/routes/admin/sessions.js @@ -11,4 +11,4 @@ router .delete("/api/admin/sessions/:userId", adminOnly, controller.invalidateUser) .delete("/api/admin/sessions/self/:sessionId", controller.invalidateSession) -module.exports = router \ No newline at end of file +module.exports = router