Skip to content

Commit

Permalink
Fix non-interactive devices first login (#222)
Browse files Browse the repository at this point in the history
Non-interactive devices first command was often not working because DB
was being created.
  • Loading branch information
Mikescops authored Mar 15, 2024
1 parent f74fb06 commit 2689b61
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/modules/database/connectAndPrepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const connectAndPrepare = async (
db.serialize();

// Create the tables and load the deviceConfiguration if it exists
const deviceConfiguration = prepareDB({ db });
let deviceConfiguration = prepareDB({ db });
if (failIfNoDB && !deviceConfiguration) {
throw new Error('No device registered in the database');
}
Expand All @@ -51,6 +51,11 @@ export const connectAndPrepare = async (
shouldNotSaveMasterPasswordIfNoDeviceKeys
);

// if the device was created for the first time we need to get the device credentials again
if (!deviceConfiguration) {
deviceConfiguration = prepareDB({ db });
}

if (deviceConfiguration && deviceConfiguration.version !== cliVersionToString(CLI_VERSION)) {
const version = stringToCliVersion(deviceConfiguration.version);

Expand Down

0 comments on commit 2689b61

Please sign in to comment.