Skip to content

Commit 2689b61

Browse files
author
Corentin Mors
authored
Fix non-interactive devices first login (#222)
Non-interactive devices first command was often not working because DB was being created.
1 parent f74fb06 commit 2689b61

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/modules/database/connectAndPrepare.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const connectAndPrepare = async (
4040
db.serialize();
4141

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

54+
// if the device was created for the first time we need to get the device credentials again
55+
if (!deviceConfiguration) {
56+
deviceConfiguration = prepareDB({ db });
57+
}
58+
5459
if (deviceConfiguration && deviceConfiguration.version !== cliVersionToString(CLI_VERSION)) {
5560
const version = stringToCliVersion(deviceConfiguration.version);
5661

0 commit comments

Comments
 (0)