@@ -523,19 +523,17 @@ class ChallengesService {
523
523
* @param {String } roleName
524
524
* @return {Promise }
525
525
*/
526
- async getResourceRoleId ( roleName ) {
526
+ async getRoleId ( roleName ) {
527
527
const params = {
528
528
name : roleName ,
529
- isActive : true ,
530
529
} ;
531
- const roles = await this . private . apiV5 . get ( `/resource-roles?${ qs . stringify ( params ) } ` )
532
- . then ( checkErrorV5 ) . then ( res => res ) ;
530
+ const roles = await this . private . proxyApi ( `/challenges/roleId?${ qs . stringify ( params ) } ` ) ;
533
531
534
- if ( _ . isEmpty ( roles . result ) ) {
532
+ if ( _ . isEmpty ( roles ) ) {
535
533
throw new Error ( 'Resource Role not found!' ) ;
536
534
}
537
535
538
- return roles . result [ 0 ] . id ;
536
+ return roles [ 0 ] . id ;
539
537
}
540
538
541
539
/**
@@ -545,7 +543,7 @@ class ChallengesService {
545
543
*/
546
544
async register ( challengeId ) {
547
545
const user = decodeToken ( this . private . tokenV3 ) ;
548
- const roleId = await this . getResourceRoleId ( 'Submitter' ) ;
546
+ const roleId = await this . getRoleId ( 'Submitter' ) ;
549
547
const params = {
550
548
challengeId,
551
549
memberHandle : user . handle ,
@@ -563,7 +561,7 @@ class ChallengesService {
563
561
*/
564
562
async unregister ( challengeId ) {
565
563
const user = decodeToken ( this . private . tokenV3 ) ;
566
- const roleId = await this . getResourceRoleId ( 'Submitter' ) ;
564
+ const roleId = await this . getRoleId ( 'Submitter' ) ;
567
565
const params = {
568
566
challengeId,
569
567
memberHandle : user . handle ,
0 commit comments