Use env vars instead of file contents (also allows for easier ci testing)

This commit is contained in:
Neshura 2024-01-03 22:53:51 +01:00
parent e6cbae1bd6
commit 1872b42d5d
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -5,28 +5,14 @@ export async function load() {
const credFile = './credentials.json'; const credFile = './credentials.json';
const socket = io('https://status.neshweb.net/'); 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 = ''; let token = '';
socket.on('connect', () => { socket.on('connect', () => {
socket.emit( socket.emit(
'login', 'login',
{ username: credentials.username, password: credentials.password, token: '' }, { username: process.env.KUMA_USERNAME, password: process.env.KUMA_PASSWORD, token: '' },
(res) => { (res) => {
token = res.token; token = res.token;
console.log('Token is:', token);
} }
); );
}); });