Skip to content

Commit

Permalink
additional checks and fixes to account creation
Browse files Browse the repository at this point in the history
  • Loading branch information
paulov-t committed May 27, 2022
1 parent 1967872 commit ea040dc
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 19 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Server Readme.md
# Tarkov Emulated Central Server

## Current Tarkov Version (working)
- 0.12.12.15.17861
## Current known working Tarkov Version
- 0.12.12.15.*

## Debugging
- Download and Install [Visual Studio Code](https://code.visualstudio.com/)
Expand All @@ -25,11 +25,19 @@ Zip the following folders & files
- user
- Server.exe

## How to use (if not compiling yourself or using a release)
- Download the latest release
- Ensure the code and the Server.exe are in the same folder
- Run Server.exe

## How to host this server to others (this may change soon)
- Open port 7777 on your router
- Open user/configs/server.json and change port value to 7777 (this can anything but this is a good easily memorable open one to use)
- Open user/configs/server.json and change ip value to your internal IP (google to find out how to find it)
- Open user/configs/server.json and change ip_backend value to your external IP (google to find out how to find it)
- Run the Server
- Provide your friends with your external IP address and port

## Known usable mods
- [SIT M4](https://github.com/paulov-t/SIT-Mod-M4) - Makes the M4 actually useful and good mod to show how to make changes of your own.

12 changes: 6 additions & 6 deletions _CreateBuildDir.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
rmdir Build /s/q
mkdir Build

copy "Server.exe" "Build/Server.exe"
Expand All @@ -8,14 +9,13 @@ xcopy "src" "Build/src/" /s/i/y
xcopy "user" "Build/user/" /s/i/y


del "Build/user/cache/" /s/q
del "Build/user/certs/" /s/q
del "Build/user/logs/" /s/q
rmdir "Build/user/cache/" /s/q
rmdir "Build/user/events/" /s/q
rmdir "Build/user/logs/" /s/q
rmdir "Build/user/profiles/" /s/q
mkdir "Build/user/profiles/" /q
rmdir "Build/user/mods" /s/q

del "Build/user/config/gameplay.json" /q
del "Build/user/config/server.json" /q
del "Build\user\configs\gameplay.json" /q
del "Build\user\configs\server.json" /q

pause
43 changes: 34 additions & 9 deletions src/Controllers/AccountController.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
const fs = require('fs');
const {AccountServer} = require('./../classes/account')
const {AccountServer} = require('./../classes/account');
const utility = require('./../../core/util/utility');

/**
* Account Controller.
* This controller should contain everything to handle Account data
*/
class AccountController
{

static Instance = new AccountController();
constructor() {
if(!fs.existsSync(`user/profiles/`)) {
fs.mkdirSync(`user/profiles/`);
}
}
/**
* Gets ALL of the account data from every profile in the user/profiles directory
* @returns all the Account data neccessary to process accounts in the server & client
*/
static getAllAccounts() {
let fullyLoadedAccounts = [];
if(!fs.existsSync(`user/profiles/`)) {
fs.mkdirSync(`user/profiles/`);
}

const profileFolders = fs.readdirSync(`user/profiles/`);
// console.log(profileFolders);
Expand Down Expand Up @@ -60,17 +71,24 @@ class AccountController


static findAccountIdByUsernameAndPassword(username, password) {
const profileFolders = fs.readdirSync(`user/profiles/`);
for (const id of profileFolders) {
if (!fileIO.exist(`user/profiles/${id}/account.json`)) continue;
let account = JSON.parse(fs.readFileSync(`user/profiles/${id}/account.json`));
if(account.email == username && account.password == password)
return id;
}
return undefined;
if(!fs.existsSync(`user/profiles/`)) {
fs.mkdirSync(`user/profiles/`);
}

const profileFolders = fs.readdirSync(`user/profiles/`);
for (const id of profileFolders) {
if (!fileIO.exist(`user/profiles/${id}/account.json`)) continue;
let account = JSON.parse(fs.readFileSync(`user/profiles/${id}/account.json`));
if(account.email == username && account.password == password)
return id;
}
return undefined;
}

static isEmailAlreadyInUse(username) {
if(!fs.existsSync(`user/profiles/`)) {
fs.mkdirSync(`user/profiles/`);
}

const profileFolders = fs.readdirSync(`user/profiles/`);
for (const id of profileFolders) {
Expand All @@ -92,6 +110,10 @@ class AccountController
}

static register(info) {
if(!fs.existsSync(`user/profiles/`)) {
fs.mkdirSync(`user/profiles/`);
}

// Get existing account from memory or cache a new one.
let accountID = AccountServer.reloadAccountByLogin(info)
if (accountID !== undefined) {
Expand All @@ -104,6 +126,9 @@ class AccountController

if(accountID === undefined) {
accountID = utility.generateNewAccountId();
if(accountID === undefined || accountID === "") {
return "FAILED";
}

AccountServer.accounts[accountID] = {
id: accountID,
Expand Down
2 changes: 1 addition & 1 deletion user/configs/server_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"port": 443,
"eventPollIntervalSec": 60,
"rebuildCache": true,
"name": "JustEmuTarkov",
"name": "JET Server (SIT Fork)",
"discord": "",
"website": "",
"runSimpleHttpServer": false,
Expand Down

0 comments on commit ea040dc

Please sign in to comment.