feat: admin general + verify account

This commit is contained in:
Nicolas Giard
2018-12-24 01:03:10 -05:00
parent 2b98a5f27a
commit fcee4c0945
22 changed files with 494 additions and 80 deletions

View File

@@ -2,6 +2,7 @@
const express = require('express')
const router = express.Router()
const moment = require('moment')
/**
* Login form
@@ -30,6 +31,17 @@ router.get('/register', async (req, res, next) => {
}
})
/**
* Verify
*/
router.get('/verify/:token', async (req, res, next) => {
const usr = await WIKI.models.userKeys.validateToken({ kind: 'verify', token: req.params.token })
await WIKI.models.users.query().patch({ isVerified: true }).where('id', usr.id)
const result = await WIKI.models.users.refreshToken(usr)
res.cookie('jwt', result.token, { expires: moment().add(1, 'years').toDate() })
res.redirect('/')
})
/**
* JWT Public Endpoints
*/