Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,10 @@ async function updateUser (req, res, next) {
}
}

// UUID of the user will not change, lets get it before we write to avoid read after write issues.
// Move lookups of immutable properties BEFORE the transaction mutation writes to completely bypass read-after-write anomalies
const requestingUserUUID = await userRepo.getUserUUID(req.ctx.user, req.ctx.org, { session })
updatedUserUUID = await userRepo.getUserUUID(req.ctx.user, org.UUID)
updatedUserUUID = await userRepo.getUserUUID(req.ctx.user, org.UUID, { session })

updatedUser = await userRepo.updateUserFull(userToEdit.UUID, body, { session }, true, requestingUserUUID)
await session.commitTransaction()
} catch (error) {
Expand Down Expand Up @@ -456,7 +457,8 @@ async function deleteUser (req, res, next) {
}

async function grantRole (req, res, next) {
const session = await mongoose.startSession()
// Explicitly configuring causalConsistency flag for clear DocumentDB context documentation
const session = await mongoose.startSession({ causalConsistency: false })
try {
const orgShortName = req.ctx.params.shortname
const username = req.ctx.params.username
Expand Down Expand Up @@ -519,7 +521,8 @@ async function grantRole (req, res, next) {
}

async function revokeRole (req, res, next) {
const session = await mongoose.startSession()
// Explicitly configuring causalConsistency flag for clear DocumentDB context documentation
const session = await mongoose.startSession({ causalConsistency: false })
try {
const orgShortName = req.ctx.params.shortname
const username = req.ctx.params.username
Expand Down
Loading