trying new auth method of using uuid instead of ip address. ip address is causing issues. Updated axios to automatically put the uuid header. Added util to remove user tokens

This commit is contained in:
kyle hoell
2020-12-08 08:13:40 -05:00
parent 025bef8f7d
commit 39b22ee2ab
18 changed files with 156 additions and 62 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
const getEnvVariables = require("./getEnvVaribables");
const getEnvVariables = require("../dist/enviroment/getEnvVariables");
getEnvVariables();
const mongoose = require("./mongoServerUtil");
const conn = mongoose.connection;
+44
View File
@@ -0,0 +1,44 @@
const getEnvVariables = require("../dist/enviroment/getEnvVariables");
getEnvVariables();
const mongoose = require("./mongoServerUtil");
const conn = mongoose.connection;
const User = require("../dist/models/user");
const waitForDatabase = () => {
return new Promise((resolve, reject) => {
if (conn.readyState !== 1) {
conn.once("open", () => {
resolve();
})
} else {
resolve();
}
})
}
const removeTokens = async() => {
console.log("\nWaiting for database...");
await waitForDatabase();
console.log("Connected to database\n");
console.log("Removing tokens from users...");
const userList = await User.find({});
await User.updateMany({}, {
tokens: [],
tempTokens: []
})
console.log("Removed tokens from", userList.length, "users");
process.exit();
}
removeTokens();