From cec774fc280f2ec7e2c2d07e9b4ce5870784a9db Mon Sep 17 00:00:00 2001 From: tgpethan Date: Wed, 2 Sep 2020 10:54:37 +0100 Subject: [PATCH] Add method of obtaining a user's class by their username --- server/util/getUserByUsername.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 server/util/getUserByUsername.js diff --git a/server/util/getUserByUsername.js b/server/util/getUserByUsername.js new file mode 100644 index 0000000..6ca0b3f --- /dev/null +++ b/server/util/getUserByUsername.js @@ -0,0 +1,10 @@ +module.exports = function(username) { + let user = null; + for (let i = 0; i < global.users.length; i++) { + if (global.users[i].username == username) { + user = global.users[i]; + break; + } + } + return user; +} \ No newline at end of file