@@ -813,10 +813,9 @@ async function populatePhases (phases, startDate, timelineTemplateId) {
813
813
* Create challenge.
814
814
* @param {Object } currentUser the user who perform operation
815
815
* @param {Object } challenge the challenge to created
816
- * @param {String } userToken the user token
817
816
* @returns {Object } the created challenge
818
817
*/
819
- async function createChallenge ( currentUser , challenge , userToken ) {
818
+ async function createChallenge ( currentUser , challenge ) {
820
819
if ( ! _ . isUndefined ( _ . get ( challenge , 'legacy.reviewType' ) ) ) {
821
820
_ . set ( challenge , 'legacy.reviewType' , _ . toUpper ( _ . get ( challenge , 'legacy.reviewType' ) ) )
822
821
}
@@ -825,7 +824,7 @@ async function createChallenge (currentUser, challenge, userToken) {
825
824
if ( challenge . status === constants . challengeStatuses . Active ) {
826
825
throw new errors . BadRequestError ( 'You cannot create an Active challenge. Please create a Draft challenge and then change the status to Active.' )
827
826
}
828
- await helper . ensureProjectExist ( challenge . projectId , userToken )
827
+ await helper . ensureProjectExist ( challenge . projectId , currentUser )
829
828
const { track, type } = await validateChallengeData ( challenge )
830
829
if ( _ . get ( type , 'isTask' ) ) {
831
830
_ . set ( challenge , 'task.isTask' , true )
@@ -1021,8 +1020,7 @@ createChallenge.schema = {
1021
1020
id : Joi . id ( ) ,
1022
1021
roleId : Joi . id ( )
1023
1022
} ) )
1024
- } ) . required ( ) ,
1025
- userToken : Joi . any ( )
1023
+ } ) . required ( )
1026
1024
}
1027
1025
1028
1026
/**
@@ -1176,16 +1174,15 @@ async function validateWinners (winners, challengeId) {
1176
1174
* @param {Object } currentUser the user who perform operation
1177
1175
* @param {String } challengeId the challenge id
1178
1176
* @param {Object } data the challenge data to be updated
1179
- * @param {String } userToken the user token
1180
1177
* @param {Boolean } isFull the flag indicate it is a fully update operation.
1181
1178
* @returns {Object } the updated challenge
1182
1179
*/
1183
- async function update ( currentUser , challengeId , data , userToken , isFull ) {
1180
+ async function update ( currentUser , challengeId , data , isFull ) {
1184
1181
if ( ! _ . isUndefined ( _ . get ( data , 'legacy.reviewType' ) ) ) {
1185
1182
_ . set ( data , 'legacy.reviewType' , _ . toUpper ( _ . get ( data , 'legacy.reviewType' ) ) )
1186
1183
}
1187
1184
if ( data . projectId ) {
1188
- await helper . ensureProjectExist ( data . projectId , userToken )
1185
+ await helper . ensureProjectExist ( data . projectId , currentUser )
1189
1186
}
1190
1187
1191
1188
helper . ensureNoDuplicateOrNullElements ( data . tags , 'tags' )
@@ -1697,11 +1694,10 @@ function sanitizeChallenge (challenge) {
1697
1694
* @param {Object } currentUser the user who perform operation
1698
1695
* @param {String } challengeId the challenge id
1699
1696
* @param {Object } data the challenge data to be updated
1700
- * @param {String } userToken the user token
1701
1697
* @returns {Object } the updated challenge
1702
1698
*/
1703
- async function fullyUpdateChallenge ( currentUser , challengeId , data , userToken ) {
1704
- return update ( currentUser , challengeId , sanitizeChallenge ( data ) , userToken , true )
1699
+ async function fullyUpdateChallenge ( currentUser , challengeId , data ) {
1700
+ return update ( currentUser , challengeId , sanitizeChallenge ( data ) , true )
1705
1701
}
1706
1702
1707
1703
fullyUpdateChallenge . schema = {
@@ -1785,20 +1781,18 @@ fullyUpdateChallenge.schema = {
1785
1781
roleId : Joi . id ( )
1786
1782
} ) . unknown ( true ) ) . optional ( ) . allow ( [ ] ) ,
1787
1783
overview : Joi . any ( ) . forbidden ( )
1788
- } ) . unknown ( true ) . required ( ) ,
1789
- userToken : Joi . any ( )
1784
+ } ) . unknown ( true ) . required ( )
1790
1785
}
1791
1786
1792
1787
/**
1793
1788
* Partially update challenge.
1794
1789
* @param {Object } currentUser the user who perform operation
1795
1790
* @param {String } challengeId the challenge id
1796
1791
* @param {Object } data the challenge data to be updated
1797
- * @param {String } userToken the user token
1798
1792
* @returns {Object } the updated challenge
1799
1793
*/
1800
- async function partiallyUpdateChallenge ( currentUser , challengeId , data , userToken ) {
1801
- return update ( currentUser , challengeId , sanitizeChallenge ( data ) , userToken )
1794
+ async function partiallyUpdateChallenge ( currentUser , challengeId , data ) {
1795
+ return update ( currentUser , challengeId , sanitizeChallenge ( data ) )
1802
1796
}
1803
1797
1804
1798
partiallyUpdateChallenge . schema = {
@@ -1879,8 +1873,7 @@ partiallyUpdateChallenge.schema = {
1879
1873
} ) . unknown ( true ) ) . min ( 1 ) ,
1880
1874
terms : Joi . array ( ) . items ( Joi . id ( ) . optional ( ) ) . optional ( ) . allow ( [ ] ) ,
1881
1875
overview : Joi . any ( ) . forbidden ( )
1882
- } ) . unknown ( true ) . required ( ) ,
1883
- userToken : Joi . any ( )
1876
+ } ) . unknown ( true ) . required ( )
1884
1877
}
1885
1878
1886
1879
/**
0 commit comments