Fix: lamassu-register with async local store
This commit is contained in:
parent
cb2e1b3907
commit
2e45098033
1 changed files with 17 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const { asyncLocalStorage, defaultStore } = require('../lib/async-storage')
|
||||||
const authentication = require('../lib/new-admin/graphql/modules/authentication')
|
const authentication = require('../lib/new-admin/graphql/modules/authentication')
|
||||||
const options = require('../lib/options')
|
const options = require('../lib/options')
|
||||||
|
|
||||||
|
|
@ -29,7 +30,8 @@ if (role !== 'user' && role !== 'superuser') {
|
||||||
process.exit(2)
|
process.exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
authentication.createRegisterToken(name, role).then(token => {
|
asyncLocalStorage.run(defaultStore(), () => {
|
||||||
|
authentication.createRegisterToken(name, role).then(token => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
console.log(`A user named ${name} already exists!`)
|
console.log(`A user named ${name} already exists!`)
|
||||||
process.exit(2)
|
process.exit(2)
|
||||||
|
|
@ -42,7 +44,8 @@ authentication.createRegisterToken(name, role).then(token => {
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log('Error: %s', err)
|
console.log('Error: %s', err)
|
||||||
process.exit(3)
|
process.exit(3)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue