refactor: user agent parsing

This commit is contained in:
Sérgio Salgado 2020-10-26 16:03:02 +00:00 committed by Josh Harvey
parent 791b275cdf
commit 839e6aae47
8 changed files with 21 additions and 63 deletions

View file

@ -68,10 +68,12 @@ app.use('/front-camera-photo', serveStatic(frontCameraBasedir, { index: false })
app.get('/api/register', (req, res, next) => {
const otp = req.query.otp
const ua = req.headers['user-agent']
const ip = req.ip
if (!otp) return next()
return login.register(req)
return login.register(otp, ua, ip)
.then(r => {
if (r.expired) return res.status(401).send('OTP expired, generate new registration link')