This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
seepur/app/Middleware/AdminAuth.js
2020-03-17 18:16:34 -04:00

21 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