File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " js-common" ,
3- "version" : " 0.0.1 " ,
3+ "version" : " 0.0.2 " ,
44 "description" : " A common Javascript code for MyCoRe development" ,
55 "repository" : " https://github.com/MyCoRe-Org/js-common.git" ,
66 "author" : " MyCoRe" ,
Original file line number Diff line number Diff line change @@ -56,12 +56,15 @@ export class OrcidUserService {
5656 */
5757 public revokeAuth = async ( orcid : string ) : Promise < void > => {
5858 try {
59- const response = await fetch ( `rsc/orcid/oauth/${ orcid } ` , {
60- method : 'DELETE' ,
61- headers : {
62- ...this . getAuthHeaders ( ) ,
63- } ,
64- } ) ;
59+ const response = await fetch (
60+ new URL ( `rsc/orcid/oauth/${ orcid } ` , this . baseUrl ) ,
61+ {
62+ method : 'DELETE' ,
63+ headers : {
64+ ...this . getAuthHeaders ( ) ,
65+ } ,
66+ }
67+ ) ;
6568 ensureOk ( response ) ;
6669 } catch ( error ) {
6770 throw handleError ( error , 'Failed to revoke ORCID' ) ;
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ export class OrcidWorkService {
4747 this . getUrl ( `${ mode } /${ orcid } /works/object/${ objectId } ` ) ,
4848 {
4949 headers : {
50+ ...this . getAuthHeaders ( ) ,
5051 Accept : 'application/json' ,
5152 } ,
5253 }
@@ -77,6 +78,7 @@ export class OrcidWorkService {
7778 const response = await fetch (
7879 this . getUrl ( `member/${ orcid } /works/object/${ objectId } ` ) ,
7980 {
81+ ...this . getAuthHeaders ( ) ,
8082 method : 'POST' ,
8183 }
8284 ) ;
@@ -94,4 +96,8 @@ export class OrcidWorkService {
9496 private getUrl ( path ?: string ) : URL {
9597 return new URL ( path ? `${ API_PATH } /${ path } ` : API_PATH , this . baseUrl ) ;
9698 }
99+
100+ private getAuthHeaders ( ) : Record < string , string > {
101+ return this . authStrategy ?.( ) ? this . authStrategy ( ) . getHeaders ( ) : { } ;
102+ }
97103}
You can’t perform that action at this time.
0 commit comments