mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-28 08:43:07 +08:00
checking if user is admin instead
This commit is contained in:
parent
469bdfe32f
commit
30a2b301eb
1 changed files with 13 additions and 9 deletions
|
@ -2,7 +2,7 @@ import joi from "joi";
|
|||
import { Router } from "express";
|
||||
import {
|
||||
asyncHandler,
|
||||
checkUserPermissions,
|
||||
checkIfUserIsAdmin,
|
||||
useInProduction,
|
||||
validateRequest,
|
||||
} from "../../middlewares/api-utils";
|
||||
|
@ -12,18 +12,17 @@ import { adminLimit } from "../../middlewares/rate-limit";
|
|||
|
||||
const router = Router();
|
||||
|
||||
const checkIfUserIsConfigurationMod = checkUserPermissions({
|
||||
criteria: (user) => {
|
||||
return !!user.configurationMod;
|
||||
},
|
||||
});
|
||||
|
||||
router.get("/", asyncHandler(ConfigurationController.getConfiguration));
|
||||
|
||||
router.patch(
|
||||
"/",
|
||||
adminLimit,
|
||||
useInProduction([authenticateRequest(), checkIfUserIsConfigurationMod]),
|
||||
useInProduction([
|
||||
authenticateRequest({
|
||||
noCache: true,
|
||||
}),
|
||||
checkIfUserIsAdmin(),
|
||||
]),
|
||||
validateRequest({
|
||||
body: {
|
||||
configuration: joi.object(),
|
||||
|
@ -35,7 +34,12 @@ router.patch(
|
|||
router.get(
|
||||
"/schema",
|
||||
adminLimit,
|
||||
useInProduction([authenticateRequest(), checkIfUserIsConfigurationMod]),
|
||||
useInProduction([
|
||||
authenticateRequest({
|
||||
noCache: true,
|
||||
}),
|
||||
checkIfUserIsAdmin(),
|
||||
]),
|
||||
asyncHandler(ConfigurationController.getSchema)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue