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

22 lines
567 B
JavaScript
Raw Normal View History

2020-03-17 22:16:34 +00:00
'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