Fixing session issues after testing a bit.
This commit is contained in:
parent
4acd094c74
commit
7f0fc5f899
|
@ -1 +1 @@
|
|||
module.exports = require("./src/security/sessions")
|
||||
module.exports = require("./src/security/sessions")
|
||||
|
|
|
@ -4,7 +4,6 @@ const redis = require("../redis/authRedis")
|
|||
|
||||
const EXPIRY_SECONDS = 3600
|
||||
|
||||
|
||||
exports.getUser = async userId => {
|
||||
const client = await redis.getUserClient()
|
||||
// try cache
|
||||
|
|
|
@ -49,13 +49,14 @@ module.exports = (noAuthPatterns = [], opts) => {
|
|||
internal = false
|
||||
if (authCookie) {
|
||||
let error = null
|
||||
const sessionId = authCookie.sessionId, userId = authCookie.userId
|
||||
const sessionId = authCookie.sessionId,
|
||||
userId = authCookie.userId
|
||||
const session = await getSession(userId, sessionId)
|
||||
if (!session) {
|
||||
error = "No session found"
|
||||
} else {
|
||||
try {
|
||||
const user = await getUser(userId)
|
||||
user = await getUser(userId)
|
||||
delete user.password
|
||||
authenticated = true
|
||||
} catch (err) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const { Client, utils } = require("./index")
|
||||
const Client = require("./index")
|
||||
const utils = require("./utils")
|
||||
|
||||
let userClient, sessionClient
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
const env = require("../environment")
|
||||
// ioredis mock is all in memory
|
||||
const Redis = env.isTest() ? require("ioredis-mock") : require("ioredis")
|
||||
const { addDbPrefix, removeDbPrefix, getRedisOptions, SEPARATOR } = require("./utils")
|
||||
const {
|
||||
addDbPrefix,
|
||||
removeDbPrefix,
|
||||
getRedisOptions,
|
||||
SEPARATOR,
|
||||
} = require("./utils")
|
||||
|
||||
const RETRY_PERIOD_MS = 2000
|
||||
const STARTUP_TIMEOUT_MS = 5000
|
||||
|
|
|
@ -2,7 +2,6 @@ const { getAppId, setCookie, getCookie, clearCookie } =
|
|||
require("@budibase/auth").utils
|
||||
const { Cookies } = require("@budibase/auth").constants
|
||||
const { getRole } = require("@budibase/auth/roles")
|
||||
const { getGlobalSelf } = require("../utilities/workerRequests")
|
||||
const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles")
|
||||
const { generateUserMetadataID } = require("../db/utils")
|
||||
const { dbExists } = require("@budibase/auth/db")
|
||||
|
@ -27,7 +26,8 @@ module.exports = async (ctx, next) => {
|
|||
}
|
||||
}
|
||||
|
||||
let appId, roleId = BUILTIN_ROLE_IDS.PUBLIC
|
||||
let appId,
|
||||
roleId = BUILTIN_ROLE_IDS.PUBLIC
|
||||
if (!ctx.user) {
|
||||
// not logged in, try to set a cookie for public apps
|
||||
appId = requestAppId
|
||||
|
|
Loading…
Reference in New Issue