Fix: lamassu-register with async local store

This commit is contained in:
csrapr 2021-05-25 18:44:05 +01:00 committed by Sérgio Salgado
parent cb2e1b3907
commit 2e45098033

View file

@ -1,5 +1,6 @@
#!/usr/bin/env node
const { asyncLocalStorage, defaultStore } = require('../lib/async-storage')
const authentication = require('../lib/new-admin/graphql/modules/authentication')
const options = require('../lib/options')
@ -29,7 +30,8 @@ if (role !== 'user' && role !== 'superuser') {
process.exit(2)
}
authentication.createRegisterToken(name, role).then(token => {
asyncLocalStorage.run(defaultStore(), () => {
authentication.createRegisterToken(name, role).then(token => {
if (!token) {
console.log(`A user named ${name} already exists!`)
process.exit(2)
@ -42,7 +44,8 @@ authentication.createRegisterToken(name, role).then(token => {
}
process.exit(0)
}).catch(err => {
}).catch(err => {
console.log('Error: %s', err)
process.exit(3)
})
})