Skip to content
Permalink
Browse files
Simplified the Secure Route
  • Loading branch information
aa7401 committed Mar 25, 2020
1 parent 902b8ce commit c96c2cad752b40c26460fdf3c5fa85c2c0fded57
Showing 1 changed file with 3 additions and 9 deletions.
@@ -3,20 +3,14 @@ const Router = require('koa-router')

const router = new Router({ prefix: '/secure' })

/**
* The secure home page.
*
* @name Home Page
* @route {GET} /
* @authentication This route requires cookie-based authentication.
*/
router.get('/', async ctx => {
try {
console.log(ctx.hbs)
if(ctx.hbs.authorised !== true) return ctx.redirect('/login?msg=you need to log in')
if(ctx.hbs.authorised !== true) return ctx.redirect('/login?msg=you need to log in&referrer=/secure')
await ctx.render('secure', ctx.hbs)
} catch(err) {
await ctx.render('error', {message: err.message})
ctx.hbs.error = err.message
await ctx.render('error', ctx.hbs)
}
})

0 comments on commit c96c2ca

Please sign in to comment.