Use env vars instead of file contents (also allows for easier ci testing)
All checks were successful
Run Tests on Code / test (push) Successful in 25s

This commit is contained in:
Neshura 2024-01-03 22:53:51 +01:00
parent dc27c9bf63
commit 6e7fe75654
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -5,28 +5,14 @@ export async function load() {
const credFile = './credentials.json';
const socket = io('https://status.neshweb.net/');
let credentials = {
username: '',
password: ''
};
if (fs.existsSync(credFile)) {
const buf = fs.readFileSync(credFile);
credentials = JSON.parse(buf.toString());
} else {
console.error('Credentials File does not exist, Socket.io connection will not work.');
}
console.log(credentials);
let token = '';
socket.on('connect', () => {
socket.emit(
'login',
{ username: credentials.username, password: credentials.password, token: '' },
{ username: process.env.KUMA_USERNAME, password: process.env.KUMA_PASSWORD, token: '' },
(res) => {
token = res.token;
console.log('Token is:', token);
}
);
});