goddamn it forgot this
This commit is contained in:
parent
e57341dbd9
commit
fc78d3fdea
@ -13,6 +13,7 @@ import emailer from '../api/emailer'
|
|||||||
import apiRouter from './api'
|
import apiRouter from './api'
|
||||||
import oauthRouter from './oauth2'
|
import oauthRouter from './oauth2'
|
||||||
import adminRouter from './admin'
|
import adminRouter from './admin'
|
||||||
|
import mcRouter from './minecraft'
|
||||||
|
|
||||||
let router = express.Router()
|
let router = express.Router()
|
||||||
|
|
||||||
@ -739,6 +740,7 @@ router.get('/activate/:token', wrap(async (req, res) => {
|
|||||||
|
|
||||||
router.use('/api', apiRouter)
|
router.use('/api', apiRouter)
|
||||||
router.use('/admin', adminRouter)
|
router.use('/admin', adminRouter)
|
||||||
|
router.use('/mc', mcRouter)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NO ROUTES BEYOND THIS POINT
|
NO ROUTES BEYOND THIS POINT
|
||||||
|
27
server/routes/minecraft.js
Normal file
27
server/routes/minecraft.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import express from 'express'
|
||||||
|
import wrap from '../../scripts/asyncRoute'
|
||||||
|
import Minecraft from '../api/minecraft'
|
||||||
|
|
||||||
|
let router = express.Router()
|
||||||
|
|
||||||
|
router.get('/', wrap(async (req, res) => {
|
||||||
|
if (!req.session.user) {
|
||||||
|
req.session.redirectUri = req.originalUrl
|
||||||
|
return res.redirect('/login')
|
||||||
|
}
|
||||||
|
|
||||||
|
let token = await Minecraft.getToken(req.session.user)
|
||||||
|
|
||||||
|
res.render('minecraft/index', {token: token.token, mcu: token.mcu})
|
||||||
|
}))
|
||||||
|
|
||||||
|
router.post('/verify/', wrap(async (req, res) => {
|
||||||
|
if (!req.body.name || !req.body.uuid || !req.body.token) return res.status(400).jsonp({error: 'Missing field.'})
|
||||||
|
|
||||||
|
let verify = await Minecraft.verifyToken(req.body.token, req.body.name, req.body.uuid)
|
||||||
|
if (!verify) return res.status(400).jsonp({error: 'Already verified.'})
|
||||||
|
|
||||||
|
res.status(200).end()
|
||||||
|
}))
|
||||||
|
|
||||||
|
module.exports = router
|
Reference in New Issue
Block a user