Skip to content

Commit bfcb3fa

Browse files
authored
Merge pull request #180 from osamhack2021/feature/frontend/#33
Bump develop from feature/frontend/#33
2 parents 4809b1f + beee6d2 commit bfcb3fa

96 files changed

Lines changed: 1769 additions & 2149 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€Žbackend/InitDB.jsβ€Ž

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ async function init() {
4949
serviceNumber: 'admin',
5050
password: 'admin',
5151
name: 'admin',
52-
rank: 'κ΄€λ¦¬μž',
52+
rank: 'λŒ€μœ„',
5353
title: 'κ΄€λ¦¬μž',
5454
status: 'admin',
5555
email: 'admin@osam.com',
5656
tel: {
5757
military: '0000',
5858
mobile: '010-0000-0000'
59-
}
59+
},
60+
profileImageUrl: 'https://t1.daumcdn.net/liveboard/holapet/0e5f90af436e4c218343073164a5f657.JPG'
6061
};
6162
users.admin = await post('/user', admin);
6263

@@ -68,7 +69,7 @@ async function init() {
6869

6970
// Create group
7071
groups.osam = await post('/group', {
71-
name: 'OSAM',
72+
name: '11사단',
7273
path: '',
7374
admins: [users.admin._id]
7475
});
@@ -83,8 +84,8 @@ async function init() {
8384
let ntcho = {
8485
serviceNumber: 'ntcho',
8586
password: 'ntcho',
86-
name: 'ntcho',
87-
rank: 'νŒ€μž₯',
87+
name: 'μ‘°λ‚˜λ‹¨',
88+
rank: '상병',
8889
title: 'νŒ€μž₯',
8990
status: 'active',
9091
email: 'ntcho@github.com',
@@ -102,17 +103,22 @@ async function init() {
102103
})).token;
103104

104105
groups.handover = await post('/group', {
105-
name: 'Handover',
106+
name: '111λŒ€λŒ€',
106107
path: groups.osam.path,
107108
admins: [users.ntcho._id]
108109
});
109110

111+
// Update ntcho's group
112+
users.ntcho = await post(`/user/${users.ntcho._id}`, {
113+
group: groups.handover._id
114+
}, 'PUT');
115+
110116
/****** Create phjppo ******/
111117
let phjppo = {
112118
serviceNumber: 'phjppo',
113119
password: 'phjppo',
114-
name: 'phjppo',
115-
rank: 'λ°±μ—”λ“œ',
120+
name: 'λ°•ν˜„μ€€',
121+
rank: '쀑사',
116122
title: 'λ°±μ—”λ“œ',
117123
status: 'active',
118124
email: 'phjppo@github.com',
@@ -130,7 +136,7 @@ async function init() {
130136
})).token;
131137

132138
groups.backend = await post('/group', {
133-
name: 'backend',
139+
name: '인사과',
134140
path: groups.handover.path,
135141
admins: [users.phjppo._id]
136142
});
@@ -139,8 +145,8 @@ async function init() {
139145
let ahnavocado = {
140146
serviceNumber: 'ahnavocado',
141147
password: 'ahnavocado',
142-
name: 'ahnavocado',
143-
rank: 'ν”„λ‘ νŠΈ',
148+
name: 'μ•ˆμˆ˜κ²Έ',
149+
rank: '병μž₯',
144150
title: 'ν”„λ‘ νŠΈ',
145151
status: 'active',
146152
email: 'ahnavocado@github.com',
@@ -158,7 +164,7 @@ async function init() {
158164
})).token;
159165

160166
groups.frontend = await post('/group', {
161-
name: 'frontend',
167+
name: 'ꡰ수과',
162168
path: groups.handover.path,
163169
admins: [users.ahnavocado._id]
164170
});

β€Žbackend/controllers/groupController.jsβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
// Only allowed fields are Searchable
1414
for(let key of keys) {
1515
if(!valids.includes(key))
16-
throw new BusinessError(`Invalid: ${key}λ‘œλŠ” 검색할 수 μ—†μŠ΅λ‹ˆλ‹€!`);
16+
throw new BusinessError(`Query invalid: ${key}λ‘œλŠ” 검색할 수 μ—†μŠ΅λ‹ˆλ‹€!`);
1717
}
1818

1919
const result = await groupService.search(req.query);
@@ -31,7 +31,7 @@ module.exports = {
3131

3232
const result = await groupService.read({ _id: group_id });
3333

34-
if(result === null) throw new NotFoundError(`NotFound: 검색결과가 μ—†μŠ΅λ‹ˆλ‹€.`);
34+
if(result === null) throw new NotFoundError(`Group not found: μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” κ·Έλ£Ήμž…λ‹ˆλ‹€.`);
3535

3636
res.status(200).send(result);
3737
} catch(err) {
@@ -64,10 +64,10 @@ module.exports = {
6464
const group = await groupService.read({ _id: group_id });
6565

6666
// Invalid group_id
67-
if(group === null) throw new NotFoundError(`NotFound: 검색결과가 μ—†μŠ΅λ‹ˆλ‹€.`);
67+
if(group === null) throw new NotFoundError(`Group not found: μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” κ·Έλ£Ήμž…λ‹ˆλ‹€.`);
6868

6969
// Admin check
70-
if(!group.admins.some(admin => admin.equals(res.locals._id))) throw new ForbiddenError(`Forbidden: 그룹의 κ΄€λ¦¬μžλ§Œ μˆ˜μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.`);
70+
if(!group.admins.some(admin => admin.equals(res.locals._id))) throw new ForbiddenError(`Access denied: 그룹의 κ΄€λ¦¬μžλ§Œ μˆ˜μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.`);
7171

7272
await groupService.update(group_id, req.body);
7373

@@ -84,7 +84,7 @@ module.exports = {
8484

8585
let result = await groupService.delete(group_id);
8686

87-
if(result === null) throw new NotFoundError(`Not Found: 검색결과가 μ—†μŠ΅λ‹ˆλ‹€.`);
87+
if(result === null) throw new NotFoundError(`Group not found: μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” κ·Έλ£Ήμž…λ‹ˆλ‹€.`);
8888

8989
res.status(204).send();
9090
} catch(err) {

β€Žbackend/controllers/itemController.jsβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
// Only allowed fields are Searchable
1717
for(let key of keys) {
1818
if(!valids.includes(key))
19-
throw new BusinessError(`Invalid: ${key}λ‘œλŠ” 검색할 수 μ—†μŠ΅λ‹ˆλ‹€!`);
19+
throw new BusinessError(`Query invalid: ${key}λ‘œλŠ” 검색할 수 μ—†μŠ΅λ‹ˆλ‹€!`);
2020
}
2121

2222
const result = await itemService.search(req.query);
@@ -50,12 +50,12 @@ module.exports = {
5050

5151
const item = await itemService.read({ _id: item_id });
5252

53-
if(item === null) throw new NotFoundError(`NotFound: 검색결과가 μ—†μŠ΅λ‹ˆλ‹€.`);
53+
if(item === null) throw new NotFoundError(`Item not found: μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” ν•­λͺ©μž…λ‹ˆλ‹€.`);
5454

5555
// Check session's read authority
5656
const user = await userService.findOne({ serviceNumber: res.locals.serviceNumber });
5757
if(!item.accessGroups.read.some(i => i.equals(user.group)))
58-
throw new ForbiddenError(`Forbidden: 읽기 κΆŒν•œμ΄ μ—†μŠ΅λ‹ˆλ‹€.`);
58+
throw new ForbiddenError(`Access denied: μ—΄λžŒ κΆŒν•œμ΄ μ—†μŠ΅λ‹ˆλ‹€.`);
5959

6060
res.status(200).send(item);
6161
} catch(err) {
@@ -106,11 +106,11 @@ module.exports = {
106106

107107
let item = await itemService.read({ _id: item_id }, { populate: false });
108108

109-
if(item === null) throw new NotFoundError(`Not Found: 검색 κ²°κ³Όκ°€ μ—†μŠ΅λ‹ˆλ‹€.`);
109+
if(item === null) throw new NotFoundError(`Item not Found: μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” ν•­λͺ©μž…λ‹ˆλ‹€.`);
110110

111111
// Check session's edit authority
112112
if(!item.accessGroups.edit.some(i => i.equals(res.locals.group)))
113-
throw new ForbiddenError(`Forbidden: μˆ˜μ • κΆŒν•œμ΄ μ—†μŠ΅λ‹ˆλ‹€.`);
113+
throw new ForbiddenError(`Access denied: μˆ˜μ • κΆŒν•œμ΄ μ—†μŠ΅λ‹ˆλ‹€.`);
114114

115115
// Append Contributor
116116
item = Object.assign(item, { contributors: [...item.contributors, res.locals._id] });
@@ -136,7 +136,7 @@ module.exports = {
136136
let item = await itemService.read({ _id: item_id }, { populate: false });
137137

138138
if(item === null)
139-
throw new NotFoundError(`Not Found: 검색 κ²°κ³Όκ°€ μ—†μŠ΅λ‹ˆλ‹€.`);
139+
throw new NotFoundError(`Item not Found: μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” ν•­λͺ©μž…λ‹ˆλ‹€.`);
140140

141141
// Algolia
142142
await algolia.deleteObject(item_id);

β€Žbackend/controllers/userController.jsβ€Ž

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const userService = require('../services/userService.js');
22
const authService = require('../services/authService.js');
3+
4+
const { BusinessError } = require('../services/errors/BusinessError.js');
5+
36
module.exports = {
47

58
search: async function(req, res) {
@@ -10,13 +13,13 @@ module.exports = {
1013
// Only allowed fields are Searchable
1114
for(let key of keys) {
1215
if(!valids.includes(key))
13-
throw new BusinessError(`${key} λŠ” 검색할 μˆ˜λŠ” μ—†λŠ” μ†μ„±μž…λ‹ˆλ‹€.`);
16+
throw new BusinessError(`Query invalid: ${key} λŠ” 검색할 μˆ˜λŠ” μ—†λŠ” μ†μ„±μž…λ‹ˆλ‹€.`);
1417
}
1518

1619

1720
const projection = {
18-
_id: true, name: true, rank: true, status: true, profileImageUrl: true,
19-
group: true, email: true, tel: true, lastLogin: true
21+
_id: true, name: true, rank: true, status: true,
22+
group: true, email: true, tel: true, lastLogin: true, profileImageUrl: true, title: true
2023
};
2124

2225
try {
@@ -31,8 +34,8 @@ module.exports = {
3134

3235
let projection = {
3336
_id: true,serviceNumber:true, name: true, rank: true, title:true,
34-
status: true, group: true, email: true, tel: true, profileImageUrl: true,
35-
lastLogin: true, firseLogin:true, bookmarks: true, subscriptions: true
37+
status: true, group: true, email: true, tel: true, lastLogin: true,
38+
lastLogin: true, firseLogin:true, bookmarks: true, subscriptions: true, profileImageUrl: true
3639
};
3740

3841
try {
@@ -71,7 +74,7 @@ module.exports = {
7174
// Only allowed fields are Searchable
7275
for(let key of keys) {
7376
if(!valids.includes(key))
74-
throw new BusinessError(`${key} λŠ” User에 μ‘΄μž¬ν•˜μ§€ μ•Šκ±°λ‚˜, λ³€κ²½ν•  수 μ—†λŠ” μ†μ„±μž…λ‹ˆλ‹€`);
77+
throw new BusinessError(`Query invalid: ${key} λŠ” User에 μ‘΄μž¬ν•˜μ§€ μ•Šκ±°λ‚˜, λ³€κ²½ν•  수 μ—†λŠ” μ†μ„±μž…λ‹ˆλ‹€`);
7578
}
7679

7780
await authService.editUserAuth(res.locals._id.toString(),req.params.id);

0 commit comments

Comments
Β (0)