forked from sagi/seepur
22 lines
567 B
JavaScript
22 lines
567 B
JavaScript
|
'use strict'
|
||
|
/** @typedef {import('@adonisjs/framework/src/Request')} Request */
|
||
|
/** @typedef {import('@adonisjs/framework/src/Response')} Response */
|
||
|
/** @typedef {import('@adonisjs/framework/src/View')} View */
|
||
|
|
||
|
class AdminAuth {
|
||
|
/**
|
||
|
* @param {object} ctx
|
||
|
* @param {Request} ctx.request
|
||
|
* @param {Function} next
|
||
|
*/
|
||
|
async handle({request, auth, response}, next) {
|
||
|
// console.log(auth.user);
|
||
|
if (!auth.user.is_admin) response.redirect('/');
|
||
|
// call next to advance the request
|
||
|
else
|
||
|
await next()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = AdminAuth
|