mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
Admin sync fixes
This commit is contained in:
parent
98df4a2586
commit
a8080c3d11
@ -1,10 +1,12 @@
|
||||
onAfterBootstrap((e) => {
|
||||
$app.onBeforeServe().add((e) => {
|
||||
const dao = $app.dao()
|
||||
const { mkLog } = /** @type {Lib} */ (require(`${__hooks}/_ph_lib.js`))
|
||||
|
||||
const log = mkLog(`admin-sync`)
|
||||
|
||||
const { email, tokenKey, passwordHash } = JSON.parse($os.getenv(`ADMIN_SYNC`))
|
||||
const { id, email, tokenKey, passwordHash } = JSON.parse(
|
||||
$os.getenv(`ADMIN_SYNC`),
|
||||
)
|
||||
|
||||
if (!email) {
|
||||
log(`Not active - skipped`)
|
||||
@ -43,9 +45,16 @@ onAfterBootstrap((e) => {
|
||||
dao
|
||||
.db()
|
||||
.newQuery(
|
||||
'insert into _admins (email, tokenKey, passwordHash) VALUES ({:email}, {:tokenKey}, {:passwordHash})',
|
||||
'insert into _admins (id,email, tokenKey, passwordHash) VALUES ({:id}, {:email}, {:tokenKey}, {:passwordHash})',
|
||||
)
|
||||
.bind({ email, tokenKey, passwordHash })
|
||||
.bind({
|
||||
id,
|
||||
email,
|
||||
tokenKey,
|
||||
passwordHash,
|
||||
created: new Date().toISOString(),
|
||||
updated: new Date().toISOString(),
|
||||
})
|
||||
.execute()
|
||||
log(`Success`)
|
||||
} catch (e) {
|
||||
|
@ -284,6 +284,7 @@ export const instanceService = mkSingleton(
|
||||
await client.getUserTokenInfo({ id })
|
||||
dbg(`Token info is`, { email, tokenKey, passwordHash })
|
||||
spawnArgs.env!.ADMIN_SYNC = stringify({
|
||||
id,
|
||||
email,
|
||||
tokenKey,
|
||||
passwordHash,
|
||||
|
Loading…
x
Reference in New Issue
Block a user