@@ -45,7 +45,8 @@ module.exports = {
4545 // create redis db for activity for the user
4646 const activity = new Activity ( { userId : data . _id } )
4747 await activity . save ( )
48-
48+ // hide password
49+ user . password = undefined
4950 return res . status ( HttpStatus . CREATED ) . json ( { user : user , token : token } )
5051 } catch ( error ) {
5152 return res . status ( HttpStatus . NOT_ACCEPTABLE ) . json ( { error : error } )
@@ -81,6 +82,9 @@ module.exports = {
8182 if ( ! user ) {
8283 return res . status ( HttpStatus . NOT_FOUND ) . json ( { msg : 'No such user exist!' } )
8384 }
85+ // hide password and tokens
86+ user . password = undefined
87+ user . tokens = [ ]
8488 return res . status ( HttpStatus . OK ) . json ( { user } )
8589 } catch ( error ) {
8690 HANDLER . handleError ( res , error )
@@ -94,6 +98,7 @@ module.exports = {
9498 'phone' ,
9599 'info' ,
96100 'about' ,
101+ 'socialMedia' ,
97102 'isDeactivated'
98103 ]
99104 // added control as per org settings
@@ -118,6 +123,9 @@ module.exports = {
118123 user [ update ] = req . body [ update ]
119124 } )
120125 await user . save ( )
126+ // hide password and tokens
127+ user . password = undefined
128+ user . tokens = [ ]
121129 return res . status ( HttpStatus . OK ) . json ( { data : user } )
122130 } catch ( error ) {
123131 return res . status ( HttpStatus . BAD_REQUEST ) . json ( { error } )
@@ -235,6 +243,7 @@ module.exports = {
235243 const inviteLink = `${ req . protocol } ://${ req . get ( 'host' ) } /user/invite/${ token } `
236244 return res . status ( HttpStatus . OK ) . json ( { inviteLink : inviteLink } )
237245 } catch ( error ) {
246+ console . log ( 'error in req' , error )
238247 HANDLER . handleError ( res , error )
239248 }
240249 } ,
@@ -308,6 +317,9 @@ module.exports = {
308317 . populate ( 'followers' , [ 'name.firstName' , 'name.lastName' , 'info.about.designation' , '_id' , 'isAdmin' ] )
309318 . populate ( 'blocked' , [ 'name.firstName' , 'name.lastName' , 'info.about.designation' , '_id' , 'isAdmin' ] )
310319 . exec ( )
320+ // hide password and tokens
321+ userData . password = undefined
322+ userData . tokens = [ ]
311323 return res . status ( HttpStatus . OK ) . json ( { user : userData } )
312324 } catch ( error ) {
313325 HANDLER . handleError ( res , error )
@@ -358,6 +370,9 @@ module.exports = {
358370 . populate ( 'followers' , [ 'name.firstName' , 'name.lastName' , 'info.about.designation' , '_id' , 'isAdmin' ] )
359371 . populate ( 'blocked' , [ 'name.firstName' , 'name.lastName' , 'info.about.designation' , '_id' , 'isAdmin' ] )
360372 . exec ( )
373+ // hide password and tokens
374+ userData . password = undefined
375+ userData . tokens = [ ]
361376 return res . status ( HttpStatus . OK ) . json ( { user : userData } )
362377 } catch ( error ) {
363378 HANDLER . handleError ( res , error )
@@ -404,6 +419,9 @@ module.exports = {
404419 if ( unblockIndex !== - 1 ) {
405420 user . blocked . splice ( unblockIndex , 1 )
406421 await user . save ( )
422+ // hide password and tokens
423+ user . password = undefined
424+ user . tokens = [ ]
407425 return res . status ( HttpStatus . OK ) . json ( { user } )
408426 }
409427 return res . status ( HttpStatus . NOT_FOUND ) . json ( { user } )
@@ -441,6 +459,9 @@ module.exports = {
441459 }
442460 user . isRemoved = true
443461 await user . save ( )
462+ // hide password and tokens
463+ user . password = undefined
464+ user . tokens = [ ]
444465 return res . status ( HttpStatus . OK ) . json ( { user } )
445466 } catch ( error ) {
446467 HANDLER . handleError ( res , error )
@@ -451,6 +472,9 @@ module.exports = {
451472 try {
452473 req . user . isActivated = ! req . user . isActivated
453474 const user = await req . user . save ( )
475+ // hide password and tokens
476+ user . password = undefined
477+ user . tokens = [ ]
454478 return res . status ( HttpStatus . OK ) . json ( { user } )
455479 } catch ( error ) {
456480 HANDLER . handleError ( error )
0 commit comments