fix: CLI key not generating on first-time install

pull/190/head
tycrek 1 year ago
parent a84bbe12e5
commit dbcb3dc777
No known key found for this signature in database
GPG Key ID: FF8A54DCE404885A

@ -135,6 +135,12 @@ export const createNewUser = (username: string, password: string, admin: boolean
if (!authData.meta) authData.meta = {};
// Check if the CLI key is set
if (!authData.cliKey || authData.cliKey.length === 0) {
log.debug('CLI key is not set, generating new key');
authData.cliKey = nanoid(32);
}
fs.writeJson(authPath, authData, { spaces: '\t' })
.then(() => log.info('Created new user', newUser.username, newUser.unid))
.then(() => resolve(newUser))
@ -330,13 +336,6 @@ export const onStart = (authFile = 'auth.json') => new Promise((resolve, reject)
return await createNewUser('ass', nanoid(), true);
}
// Check if the CLI key is set
if (!json.cliKey || json.cliKey.length === 0) {
log.debug('CLI key is not set, generating new key');
json.cliKey = nanoid(32);
fs.writeJsonSync(file, json, { spaces: '\t' });
}
// Add users to the map
return json.users.forEach((user) => users.push(user));
})

Loading…
Cancel
Save