File tree 4 files changed +7
-21
lines changed
4 files changed +7
-21
lines changed Original file line number Diff line number Diff line change @@ -70,12 +70,7 @@ const updateDocument = (req, res) => {
70
70
} ) ;
71
71
}
72
72
return document
73
- . update ( {
74
- title : req . body . title || document . title ,
75
- content : req . body . content || document . content ,
76
- access : req . body . access || document . access ,
77
- userId : document . userId
78
- } )
73
+ . update ( req . body )
79
74
. then ( ( ) => res . status ( 200 ) . send ( {
80
75
document,
81
76
message : 'Document updated successfully'
Original file line number Diff line number Diff line change @@ -94,9 +94,7 @@ const updateRole = (req, res) => {
94
94
} ) ;
95
95
}
96
96
return role
97
- . update ( {
98
- title : req . body . title || role . title
99
- } )
97
+ . update ( req . body )
100
98
. then ( ( ) => res . status ( 200 ) . json ( {
101
99
message : 'Role updated successfully' ,
102
100
role
Original file line number Diff line number Diff line change @@ -190,13 +190,12 @@ const updateUser = (req, res) => {
190
190
if ( ! user ) {
191
191
return res . status ( 404 ) . json ( { message : 'User not found' } ) ;
192
192
}
193
+
194
+ if ( req . body . password ) {
195
+ req . body . password = hash ;
196
+ }
193
197
return user
194
- . update ( {
195
- fullName : req . body . fullName || user . fullName ,
196
- userName : req . body . userName || user . userName ,
197
- email : req . body . email || user . email ,
198
- password : hash || user . password ,
199
- } )
198
+ . update ( req . body )
200
199
. then ( ( updatedUser ) => {
201
200
res . status ( 200 ) . send ( {
202
201
userUpdate : {
Original file line number Diff line number Diff line change @@ -5,12 +5,6 @@ import helper from '../controllers/mockData';
5
5
const expect = chai . expect ;
6
6
7
7
describe ( 'User Model' , ( ) => {
8
- const requiredFields = [
9
- 'userName' ,
10
- 'fullName' ,
11
- 'email' ,
12
- 'password'
13
- ] ;
14
8
const uniqueFields = [ 'userName' , 'email' ] ;
15
9
const defaultRoleId = 2 ;
16
10
let regularUser ;
You can’t perform that action at this time.
0 commit comments