-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the User.isActive flag (#14871)
- Loading branch information
1 parent
8365c38
commit e81741f
Showing
13 changed files
with
371 additions
and
164 deletions.
There are no files selected for viewing
37 changes: 0 additions & 37 deletions
37
services/app-api/handlers/users/post/activateDeactivateUser.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
services/database/scripts/removeActiveFlagFromUserObject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const { DynamoDBClient } = require("@aws-sdk/client-dynamodb"); | ||
const { | ||
DynamoDBDocumentClient, | ||
paginateScan, | ||
PutCommand, | ||
} = require("@aws-sdk/lib-dynamodb"); | ||
|
||
/* | ||
* ENVIRONMENT VARIABLES TO SET: | ||
* AUTH_USER_TABLE_NAME: the name of the table in Dynamo | ||
* DYNAMODB_URL: the local URL if local; undefined otherwise | ||
* [anything needed for AWS auth, if not local] | ||
*/ | ||
const { | ||
AUTH_USER_TABLE_NAME, | ||
DYNAMODB_URL, | ||
} = process.env; | ||
|
||
const logger = { | ||
debug: () => {}, | ||
info: console.info, | ||
warn: console.warn, | ||
error: console.error, | ||
}; | ||
|
||
const localConfig = { | ||
endpoint: DYNAMODB_URL, | ||
region: "localhost", | ||
credentials: { | ||
accessKeyId: "LOCALFAKEKEY", // pragma: allowlist secret | ||
secretAccessKey: "LOCALFAKESECRET", // pragma: allowlist secret | ||
}, | ||
logger, | ||
}; | ||
|
||
const awsConfig = { | ||
region: "us-east-1", | ||
logger, | ||
}; | ||
|
||
const getConfig = () => { | ||
return DYNAMODB_URL ? localConfig : awsConfig; | ||
}; | ||
|
||
const client = DynamoDBDocumentClient.from(new DynamoDBClient(getConfig())); | ||
|
||
(async function () { | ||
let scannedCount = 0; | ||
let updatedCount = 0; | ||
console.log("Scanning..."); | ||
for await (let page of paginateScan({ client }, { TableName: AUTH_USER_TABLE_NAME })) { | ||
if (!page.Items) continue; | ||
for (let user of page.Items) { | ||
scannedCount += 1; | ||
if (!("isActive" in user)) continue; | ||
|
||
delete user.isActive; | ||
await client.send(new PutCommand({ | ||
TableName: AUTH_USER_TABLE_NAME, | ||
Item: user, | ||
})); | ||
|
||
updatedCount += 1; | ||
} | ||
} | ||
console.log(`Scanned ${scannedCount} total users`); | ||
console.log(`Found ${updatedCount} users in need of update`); | ||
console.log("All updates successful"); | ||
})(); |
Oops, something went wrong.