From 96b24ab54027e2c8f20db8f8d850a8357ff4efae Mon Sep 17 00:00:00 2001 From: grulla79 Date: Mon, 8 Jul 2024 01:39:04 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20user=20=EC=8A=A4=ED=82=A4?= =?UTF-8?q?=EB=A7=88=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/user/user.model.js | 6 +++--- src/routes/word/word.repository.js | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/routes/user/user.model.js b/src/routes/user/user.model.js index fabaff8..dddfc3b 100644 --- a/src/routes/user/user.model.js +++ b/src/routes/user/user.model.js @@ -4,15 +4,15 @@ const bcrypt = require('bcrypt'); const requestSchema = new mongoose.Schema( { word: { type: String, required: true }, - awkPron: [{ type: String }], - comPron: [ + awkPron: { type: String }, + comPron: { type: String, required: function () { return this.type === 'mod'; }, }, - ], + info: { type: String }, suggestedBy: { type: String, required: true }, type: { type: String, enum: ['add', 'mod'], required: true }, diff --git a/src/routes/word/word.repository.js b/src/routes/word/word.repository.js index 1588088..3fa3095 100644 --- a/src/routes/word/word.repository.js +++ b/src/routes/word/word.repository.js @@ -65,8 +65,7 @@ exports.getAllWords = async (isSorted, page, limit) => { exports.addWord = async (requestId, formData) => { try { - // requestId에 해당하는 request를 찾습니다. - console.log("addWord 진입!!!!!!!!", requestId, formData) + // requestId에 해당하는 request를 찾습니다. const user = await User.findOne({ 'requests._id': requestId }); if (!user) { console.log('User with the given request not found'); @@ -79,7 +78,6 @@ exports.addWord = async (requestId, formData) => { return null; } - const newWord = new Word({ word: formData.devTerm, awkPron: formData.awkPron, From f9e339a8b8526f4eb568c3a8ff28539f3f4f9079 Mon Sep 17 00:00:00 2001 From: grulla79 Date: Tue, 9 Jul 2024 14:41:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=BA=20=EC=82=AC=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=20=EC=9A=94=EC=B2=AD=20=EA=B0=9C=EB=B0=9C=EC=9A=A9=EC=96=B4=20?= =?UTF-8?q?db=20=EC=9C=A0=ED=9A=A8=EC=84=B1=EA=B2=80=EC=A6=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/user/user.model.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/routes/user/user.model.js b/src/routes/user/user.model.js index dddfc3b..ad510f6 100644 --- a/src/routes/user/user.model.js +++ b/src/routes/user/user.model.js @@ -3,7 +3,11 @@ const bcrypt = require('bcrypt'); const requestSchema = new mongoose.Schema( { - word: { type: String, required: true }, + word: { + type: String, + required: true, + match: /^[a-zA-Z0-9\s!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]*$/ + }, awkPron: { type: String }, comPron: {