Skip to content

Commit

Permalink
Update migrations/1719409568000-multiuser.js
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
lelemm and coderabbitai[bot] authored Nov 25, 2024
1 parent 979bec5 commit 1a9bb6d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions migrations/1719409568000-multiuser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,15 @@ export const up = async function () {
`,
);

let sessionRow = accountDb.first(
'SELECT * FROM sessions WHERE auth_method IS NULL',
);

let token = sessionRow ? sessionRow.token : uuid.v4();

const userId = uuid.v4();
accountDb.mutate(
'INSERT INTO users (id, user_name, display_name, enabled, owner, role) VALUES (?, ?, ?, 1, 1, ?)',
[userId, '', '', 'ADMIN'],
);

accountDb.mutate(
'UPDATE sessions SET user_id = ?, expires_at = ?, auth_method = ? WHERE token = ?',
[userId, -1, 'password', token],
'UPDATE sessions SET user_id = ?, expires_at = ?, auth_method = ? WHERE auth_method IS NULL',
[userId, -1, 'password'],
);
});
};
Expand Down

0 comments on commit 1a9bb6d

Please sign in to comment.