mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-11 17:50:39 +01:00
14 lines
398 B
JavaScript
Vendored
14 lines
398 B
JavaScript
Vendored
/**
|
|
* Allows an authenticated user to access the route only if he has administrator rights
|
|
*/
|
|
export default async function adminOnly({ to, next, nextMiddleware, stores }) {
|
|
const { user } = stores
|
|
const { notify } = stores
|
|
|
|
if (! user.isAdmin) {
|
|
let err = new Error('unauthorized')
|
|
err.response.status = 403
|
|
notify.error(err)
|
|
}
|
|
else nextMiddleware()
|
|
} |