admin sync fixes

This commit is contained in:
Ben Allfree 2024-01-13 22:52:30 +00:00
parent 6c370c13ee
commit 4a070eb09b

View File

@ -4,12 +4,19 @@ $app.onBeforeServe().add((e) => {
const log = mkLog(`admin-sync`)
const { id, email, tokenKey, passwordHash } = JSON.parse(
$os.getenv(`ADMIN_SYNC`),
)
const { id, email, tokenKey, passwordHash } = (() => {
try {
return /** @type{{id:string, email:string, tokenKey:string,passwordHash:string}} */ (
JSON.parse($os.getenv(`ADMIN_SYNC`))
)
} catch (e) {
return { id: '', email: '', tokenKey: '', passwordHash: '' }
}
})()
if (!email) {
log(`Not active - skipped`)
return
}
const result = new DynamicModel({