Refactor required route role
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Router from "koa-router";
|
||||
import { UserRole } from "@shared/types";
|
||||
import auth from "@server/middlewares/authentication";
|
||||
import { transaction } from "@server/middlewares/transaction";
|
||||
import validate from "@server/middlewares/validate";
|
||||
@@ -16,7 +17,7 @@ const router = new Router();
|
||||
|
||||
router.post(
|
||||
"authenticationProviders.info",
|
||||
auth({ admin: true }),
|
||||
auth({ role: UserRole.Admin }),
|
||||
validate(T.AuthenticationProvidersInfoSchema),
|
||||
async (ctx: APIContext<T.AuthenticationProvidersInfoReq>) => {
|
||||
const { id } = ctx.input.body;
|
||||
@@ -34,7 +35,7 @@ router.post(
|
||||
|
||||
router.post(
|
||||
"authenticationProviders.update",
|
||||
auth({ admin: true }),
|
||||
auth({ role: UserRole.Admin }),
|
||||
validate(T.AuthenticationProvidersUpdateSchema),
|
||||
transaction(),
|
||||
async (ctx: APIContext<T.AuthenticationProvidersUpdateReq>) => {
|
||||
@@ -79,7 +80,7 @@ router.post(
|
||||
|
||||
router.post(
|
||||
"authenticationProviders.list",
|
||||
auth({ admin: true }),
|
||||
auth({ role: UserRole.Admin }),
|
||||
async (ctx: APIContext) => {
|
||||
const { user } = ctx.state.auth;
|
||||
authorize(user, "read", user.team);
|
||||
|
||||
Reference in New Issue
Block a user