Remove userManager and all usages of it

This commit is contained in:
tgpethan 2020-09-07 17:35:37 +01:00
parent 3e15b9ada3
commit 36715a7682
7 changed files with 19 additions and 66 deletions

View file

@ -9,8 +9,7 @@ const debugMode = true;
global.consoleHelper = require("./consoleHelper.js");
const serverHandler = require("./server/serverHandler.js"),
userManager = require("./server/userManager.js");
const serverHandler = require("./server/serverHandler.js");
app.use(busboy());

View file

@ -1,5 +1,4 @@
const osu = require("osu-packet"),
userManager = require("../userManager.js");
const osu = require("osu-packet");
module.exports = function(CurrentPacket, CurrentUser) {
const osuPacketWriter = new osu.Bancho.Writer;

View file

@ -1,5 +1,4 @@
const osu = require("osu-packet"),
userManager = require("../userManager.js");
const osu = require("osu-packet");
module.exports = function(currentUser) {
const osuPacketWriter = new osu.Bancho.Writer;

View file

@ -3,8 +3,9 @@ const osu = require("osu-packet"),
{ v4: uuid } = require('uuid'),
request = require("sync-request"),
userManager = require("./userManager.js"),
DatabaseHelper = require("./DatabaseHelper.js"),
getUserByUsername = require("./util/getUserByUsername.js"),
getUserByToken = require("./util/getUserByToken.js"),
countryHelper = require("./countryHelper.js"),
loginHelper = require("./loginHelper.js");
@ -43,7 +44,7 @@ module.exports = function(req, res, loginInfo) {
const newClientToken = uuid();
// Make sure user is not already connected, kick off if so.
const checkForPreexistingUser = userManager.getUserFromUsername(loginInfo.username);
const checkForPreexistingUser = getUserByUsername(loginInfo.username);
if (checkForPreexistingUser != null) {
if (checkForPreexistingUser.uuid != newClientToken) {
let userCurrentIndex;
@ -63,7 +64,7 @@ module.exports = function(req, res, loginInfo) {
global.users.push(new User(userDB.id, loginInfo.username, newClientToken, new Date().getTime()));
// Retreive the newly created user
const userClass = userManager.getUserFromToken(newClientToken);
const userClass = getUserByToken(newClientToken);
// Get user's data from the database
userClass.getNewUserInformationFromDatabase();

View file

@ -3,8 +3,8 @@ const osu = require("osu-packet"),
packetIDs = require("./packetIDs.json"),
loginHandler = require("./loginHandler.js"),
parseUserData = require("./util/parseUserData.js"),
userManager = require("./userManager.js"),
User = require("./User.js"),
getUserFromToken = require("./util/getUserByToken.js"),
bakedResponses = require("./bakedResponses.js"),
Streams = require("./Streams.js");
@ -116,7 +116,7 @@ module.exports = function(req, res) {
// Client has a token, let's see what they want.
try {
// Get the current user
const userClass = userManager.getUserFromToken(requestTokenString);
const userClass = getUserFromToken(requestTokenString);
// Make sure the client's token isn't invalid
if (userClass != null) {

View file

@ -1,55 +0,0 @@
module.exports = {
getUserFromID:function(id) {
let userToReturn;
for (let i = 0; i < global.users.length; i++) {
if (global.users[i].id == id) {
userToReturn = global.users[i];
i = global.users.length;
} else {
continue;
}
}
return userToReturn;
},
getUserFromUsername:function(username) {
let userToReturn;
for (let i = 0; i < global.users.length; i++) {
if (global.users[i].username == username) {
userToReturn = global.users[i];
break;
} else {
continue;
}
}
return userToReturn;
},
getUserFromToken:function(token) {
let userToReturn;
for (let i = 0; i < global.users.length; i++) {
if (global.users[i].uuid == token) {
userToReturn = global.users[i];
i = global.users.length;
} else {
continue;
}
}
return userToReturn;
},
queueActionForAll:function(action) {
for (let i = 0; i < global.users.length; i++) {
global.users[i].addActionToQueue(action);
}
},
queueActionForAllWithoutCallingUser:function(action, token) {
for (let i = 0; i < global.users.length; i++) {
if (global.users[i].uuid == token) {
continue;
}
global.users[i].addActionToQueue(action);
}
}
}

View file

@ -0,0 +1,10 @@
module.exports = function(token) {
let user = null;
for (let i = 0; i < global.users.length; i++) {
if (global.users[i].uuid == token) {
user = global.users[i];
break;
}
}
return user;
}