|
@@ -4,6 +4,8 @@ import express from 'express';
|
|
|
|
|
|
|
|
import { SupportedAction } from '~/interfaces/activity';
|
|
import { SupportedAction } from '~/interfaces/activity';
|
|
|
import { accessTokenParser } from '~/server/middlewares/access-token-parser';
|
|
import { accessTokenParser } from '~/server/middlewares/access-token-parser';
|
|
|
|
|
+import adminRequiredFactory from '~/server/middlewares/admin-required';
|
|
|
|
|
+import loginRequiredFactory from '~/server/middlewares/login-required';
|
|
|
import { GlobalNotificationSettingType } from '~/server/models/GlobalNotificationSetting';
|
|
import { GlobalNotificationSettingType } from '~/server/models/GlobalNotificationSetting';
|
|
|
import { configManager } from '~/server/service/config-manager';
|
|
import { configManager } from '~/server/service/config-manager';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
@@ -182,8 +184,8 @@ const validator = {
|
|
|
*/
|
|
*/
|
|
|
/** @param {import('~/server/crowi').default} crowi Crowi instance */
|
|
/** @param {import('~/server/crowi').default} crowi Crowi instance */
|
|
|
module.exports = (crowi) => {
|
|
module.exports = (crowi) => {
|
|
|
- const Strictly = require('../../middlewares/login-required')(crowi);
|
|
|
|
|
- const adminRequired = require('../../middlewares/admin-required')(crowi);
|
|
|
|
|
|
|
+ const loginRequiredStrictly = loginRequiredFactory(crowi);
|
|
|
|
|
+ const adminRequired = adminRequiredFactory(crowi);
|
|
|
const addActivity = generateAddActivityMiddleware(crowi);
|
|
const addActivity = generateAddActivityMiddleware(crowi);
|
|
|
|
|
|
|
|
const activityEvent = crowi.events.activity;
|
|
const activityEvent = crowi.events.activity;
|
|
@@ -219,7 +221,7 @@ module.exports = (crowi) => {
|
|
|
router.get(
|
|
router.get(
|
|
|
'/',
|
|
'/',
|
|
|
accessTokenParser([SCOPE.READ.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
accessTokenParser([SCOPE.READ.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
|
- Strictly,
|
|
|
|
|
|
|
+ loginRequiredStrictly,
|
|
|
adminRequired,
|
|
adminRequired,
|
|
|
async (req, res) => {
|
|
async (req, res) => {
|
|
|
const notificationParams = {
|
|
const notificationParams = {
|
|
@@ -283,7 +285,7 @@ module.exports = (crowi) => {
|
|
|
router.post(
|
|
router.post(
|
|
|
'/user-notification',
|
|
'/user-notification',
|
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
|
- Strictly,
|
|
|
|
|
|
|
+ loginRequiredStrictly,
|
|
|
adminRequired,
|
|
adminRequired,
|
|
|
addActivity,
|
|
addActivity,
|
|
|
validator.userNotification,
|
|
validator.userNotification,
|
|
@@ -343,7 +345,7 @@ module.exports = (crowi) => {
|
|
|
router.delete(
|
|
router.delete(
|
|
|
'/user-notification/:id',
|
|
'/user-notification/:id',
|
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
|
- Strictly,
|
|
|
|
|
|
|
+ loginRequiredStrictly,
|
|
|
adminRequired,
|
|
adminRequired,
|
|
|
addActivity,
|
|
addActivity,
|
|
|
async (req, res) => {
|
|
async (req, res) => {
|
|
@@ -400,7 +402,7 @@ module.exports = (crowi) => {
|
|
|
router.get(
|
|
router.get(
|
|
|
'/global-notification/:id',
|
|
'/global-notification/:id',
|
|
|
accessTokenParser([SCOPE.READ.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
accessTokenParser([SCOPE.READ.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
|
- Strictly,
|
|
|
|
|
|
|
+ loginRequiredStrictly,
|
|
|
adminRequired,
|
|
adminRequired,
|
|
|
validator.globalNotification,
|
|
validator.globalNotification,
|
|
|
async (req, res) => {
|
|
async (req, res) => {
|
|
@@ -453,7 +455,7 @@ module.exports = (crowi) => {
|
|
|
router.post(
|
|
router.post(
|
|
|
'/global-notification',
|
|
'/global-notification',
|
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
|
- Strictly,
|
|
|
|
|
|
|
+ loginRequiredStrictly,
|
|
|
adminRequired,
|
|
adminRequired,
|
|
|
addActivity,
|
|
addActivity,
|
|
|
validator.globalNotification,
|
|
validator.globalNotification,
|
|
@@ -528,7 +530,7 @@ module.exports = (crowi) => {
|
|
|
router.put(
|
|
router.put(
|
|
|
'/global-notification/:id',
|
|
'/global-notification/:id',
|
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
|
- Strictly,
|
|
|
|
|
|
|
+ loginRequiredStrictly,
|
|
|
adminRequired,
|
|
adminRequired,
|
|
|
addActivity,
|
|
addActivity,
|
|
|
validator.globalNotification,
|
|
validator.globalNotification,
|
|
@@ -613,7 +615,7 @@ module.exports = (crowi) => {
|
|
|
router.put(
|
|
router.put(
|
|
|
'/notify-for-page-grant',
|
|
'/notify-for-page-grant',
|
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
|
- Strictly,
|
|
|
|
|
|
|
+ loginRequiredStrictly,
|
|
|
adminRequired,
|
|
adminRequired,
|
|
|
addActivity,
|
|
addActivity,
|
|
|
validator.notifyForPageGrant,
|
|
validator.notifyForPageGrant,
|
|
@@ -697,7 +699,7 @@ module.exports = (crowi) => {
|
|
|
router.put(
|
|
router.put(
|
|
|
'/global-notification/:id/enabled',
|
|
'/global-notification/:id/enabled',
|
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
|
- Strictly,
|
|
|
|
|
|
|
+ loginRequiredStrictly,
|
|
|
adminRequired,
|
|
adminRequired,
|
|
|
addActivity,
|
|
addActivity,
|
|
|
async (req, res) => {
|
|
async (req, res) => {
|
|
@@ -757,7 +759,7 @@ module.exports = (crowi) => {
|
|
|
router.delete(
|
|
router.delete(
|
|
|
'/global-notification/:id',
|
|
'/global-notification/:id',
|
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
|
|
|
- Strictly,
|
|
|
|
|
|
|
+ loginRequiredStrictly,
|
|
|
adminRequired,
|
|
adminRequired,
|
|
|
addActivity,
|
|
addActivity,
|
|
|
async (req, res) => {
|
|
async (req, res) => {
|