Init -- well, everything.

This commit is contained in:
oitsjustjose 2020-07-03 21:55:53 -05:00
commit 4645561d33
9 changed files with 352 additions and 0 deletions

28
src/app/routes/routes.ts Normal file
View file

@ -0,0 +1,28 @@
import { Application } from "express"
import { PassportStatic } from "passport"
import * as Auth from './auth'
export const init = (app: Application, passport: PassportStatic) => {
app.get('/', async (req, res) => {
if (req.isAuthenticated() && req.user) {
res.render('home')
} else {
res.redirect('/login?origin=/')
}
})
app.put('/', async (req, res) => {
if (req.isAuthenticated() && req.user) {
req.user.configs.push({
name: req.body.name,
conf: req.body.config
})
} else {
res.status(401).send({
error: 'Not logged in!'
})
}
})
Auth.init(app, passport)
}