Make it easier to save new accounts
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import fs from 'fs';
|
||||
import https from 'https';
|
||||
import prompt from 'prompt';
|
||||
import Moniker from 'moniker';
|
||||
@@ -166,10 +167,35 @@ prompt.get(['number', 'referral'], (err, res) => {
|
||||
const auth = confirmResult.response;
|
||||
if (!auth.auth) {
|
||||
verification.create(newUser, referral, (createResult) => {
|
||||
console.log('createResult', createResult);
|
||||
if (createResult.response) {
|
||||
const account = createResult.response;
|
||||
console.log('Creation result:', account);
|
||||
fs.readFile('config.json', 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
console.log('Error reading config for writing: ', err);
|
||||
} else {
|
||||
const configObj = JSON.parse(data);
|
||||
configObj.players.push({
|
||||
"accessToken": account.accessToken,
|
||||
"admin": account.admin,
|
||||
"authToken": account.authToken,
|
||||
"avatarUrl": account.avatarUrl,
|
||||
"guest": account.guest,
|
||||
"loginToken": account.loginToken,
|
||||
"userId": account.userId,
|
||||
"username": account.username,
|
||||
"tester": account.tester,
|
||||
});
|
||||
const configJSON = JSON.stringify(configObj, null, 2);
|
||||
fs.writeFile('config.json', configJSON, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
console.log('Error saving config: ', err);
|
||||
} else {
|
||||
console.log('Done!');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (createResult.error) console.log('Error creating account:', createResult.error);
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user