|
@@ -1,9 +1,11 @@
|
|
|
-import { body } from 'express-validator';
|
|
|
|
|
|
|
+import { body, checkSchema } from 'express-validator';
|
|
|
|
|
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
import { listLocaleIds } from '~/utils/locale-utils';
|
|
import { listLocaleIds } from '~/utils/locale-utils';
|
|
|
|
|
|
|
|
|
|
+import EditorSettings from '../../models/editor-settings';
|
|
|
|
|
+
|
|
|
const logger = loggerFactory('growi:routes:apiv3:personal-setting');
|
|
const logger = loggerFactory('growi:routes:apiv3:personal-setting');
|
|
|
|
|
|
|
|
const express = require('express');
|
|
const express = require('express');
|
|
@@ -12,6 +14,7 @@ const passport = require('passport');
|
|
|
|
|
|
|
|
const router = express.Router();
|
|
const router = express.Router();
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @swagger
|
|
* @swagger
|
|
|
* tags:
|
|
* tags:
|
|
@@ -68,7 +71,7 @@ module.exports = (crowi) => {
|
|
|
const csrf = require('../../middlewares/csrf')(crowi);
|
|
const csrf = require('../../middlewares/csrf')(crowi);
|
|
|
const apiV3FormValidator = require('../../middlewares/apiv3-form-validator')(crowi);
|
|
const apiV3FormValidator = require('../../middlewares/apiv3-form-validator')(crowi);
|
|
|
|
|
|
|
|
- const { User, ExternalAccount, EditorSettings } = crowi.models;
|
|
|
|
|
|
|
+ const { User, ExternalAccount } = crowi.models;
|
|
|
|
|
|
|
|
const validator = {
|
|
const validator = {
|
|
|
personal: [
|
|
personal: [
|
|
@@ -99,7 +102,14 @@ module.exports = (crowi) => {
|
|
|
body('accountId').isString().not().isEmpty(),
|
|
body('accountId').isString().not().isEmpty(),
|
|
|
],
|
|
],
|
|
|
editorSettings: [
|
|
editorSettings: [
|
|
|
- body('isTextlintEnabled').isBoolean(),
|
|
|
|
|
|
|
+ checkSchema({
|
|
|
|
|
+ textlintSettings: {
|
|
|
|
|
+ isTextlintEnabled: { isBoolean: true },
|
|
|
|
|
+ textlintRules: [
|
|
|
|
|
+ { name: { isString: true }, options: { isString: true }, isEnabled: { isBoolean: true } },
|
|
|
|
|
+ ],
|
|
|
|
|
+ },
|
|
|
|
|
+ }),
|
|
|
],
|
|
],
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -519,7 +529,7 @@ module.exports = (crowi) => {
|
|
|
* type: object
|
|
* type: object
|
|
|
* description: editor settings
|
|
* description: editor settings
|
|
|
*/
|
|
*/
|
|
|
- router.get('/editor-settings', accessTokenParser, loginRequiredStrictly, csrf, validator.editorSettings, apiV3FormValidator, async(req, res) => {
|
|
|
|
|
|
|
+ router.get('/editor-settings', accessTokenParser, loginRequiredStrictly, async(req, res) => {
|
|
|
try {
|
|
try {
|
|
|
const query = { userId: req.user.id };
|
|
const query = { userId: req.user.id };
|
|
|
const response = await EditorSettings.findOne(query);
|
|
const response = await EditorSettings.findOne(query);
|