34 lines
694 B
JavaScript
Executable file
34 lines
694 B
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
const path = require('path')
|
|
require('dotenv').config({ path: path.resolve(__dirname, '../.env') })
|
|
|
|
const login = require('../lib/admin/login')
|
|
|
|
const name = process.argv[2]
|
|
const domain = process.env.HOSTNAME
|
|
|
|
if (!domain) {
|
|
console.error('No hostname configured in the environment')
|
|
process.exit(1)
|
|
}
|
|
|
|
if (!name) {
|
|
console.log('Usage: lamassu-register <username>')
|
|
process.exit(2)
|
|
}
|
|
|
|
login.generateOTP(name)
|
|
.then(otp => {
|
|
if (domain === 'localhost') {
|
|
console.log(`https://${domain}:8070?otp=${otp}`)
|
|
} else {
|
|
console.log(`https://${domain}?otp=${otp}`)
|
|
}
|
|
|
|
process.exit(0)
|
|
})
|
|
.catch(err => {
|
|
console.log('Error: %s', err)
|
|
process.exit(3)
|
|
})
|