Skip to content

Commit

Permalink
fix(Auth): Fixed auth token missing error
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-ep committed Jul 26, 2021
1 parent 32d7bfa commit 80de8eb
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 37 deletions.
25 changes: 20 additions & 5 deletions src/endpoints/account-addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class AccountAddressesEndpoint extends BaseExtend {
'GET',
undefined,
undefined,
token
true,
null,
null,
{ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token }
)
}

Expand All @@ -25,7 +28,10 @@ class AccountAddressesEndpoint extends BaseExtend {
'GET',
undefined,
undefined,
token
true,
null,
null,
{ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token }
)
}

Expand All @@ -35,7 +41,10 @@ class AccountAddressesEndpoint extends BaseExtend {
'POST',
{ ...body, type: singularize(this.endpoint) },
undefined,
token
true,
null,
null,
{ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token }
)
}

Expand All @@ -45,7 +54,10 @@ class AccountAddressesEndpoint extends BaseExtend {
'DELETE',
undefined,
undefined,
token
true,
null,
null,
{ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token }
)
}

Expand All @@ -55,7 +67,10 @@ class AccountAddressesEndpoint extends BaseExtend {
'PUT',
{ ...body, type: singularize(this.endpoint) },
undefined,
token
true,
null,
null,
{ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token }
)
}
}
Expand Down
1 change: 0 additions & 1 deletion src/endpoints/account-members.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class AccountMembersEndpoint extends BaseExtend {
'GET',
undefined,
token,
undefined,
this,
headers
)
Expand Down
1 change: 0 additions & 1 deletion src/endpoints/account-memberships.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class AccountMembershipsEndpoint extends BaseExtend {
'GET',
undefined,
token,
undefined,
this
)

Expand Down
1 change: 0 additions & 1 deletion src/endpoints/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class AccountsEndpoint extends CRUDExtend {
'GET',
undefined,
token,
undefined,
this,
headers
)
Expand Down
1 change: 0 additions & 1 deletion src/endpoints/authentication-realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class AuthenticationRealmsEndpoint extends CRUDExtend {
'GET',
undefined,
token,
undefined,
this,
headers
)
Expand Down
1 change: 0 additions & 1 deletion src/endpoints/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class CatalogEndpoint extends CatalogQuery {
'GET',
undefined,
token,
undefined,
this
)

Expand Down
1 change: 0 additions & 1 deletion src/endpoints/customers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class CustomersEndpoint extends CRUDExtend {
'POST',
tokenRequestBody,
null,
undefined,
{
...headers
}
Expand Down
9 changes: 1 addition & 8 deletions src/endpoints/merchant-realm-mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ class MerchantRealmMappings {
}

All(token = null) {
this.call = this.request.send(
this.endpoint,
'GET',
undefined,
token,
undefined,
this
)
this.call = this.request.send(this.endpoint, 'GET', undefined, token, this)

return this.call
}
Expand Down
5 changes: 1 addition & 4 deletions src/endpoints/node-relationships.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ class NodeRelationshipsEndpoint {
return this.request.send(
`hierarchies/${hierarchyId}/nodes/${nodeId}/relationships/parent`,
'PUT',
{
...body,
type: singularize(this.endpoint)
},
{ ...body, type: singularize(this.endpoint) },
token
)
}
Expand Down
2 changes: 0 additions & 2 deletions src/endpoints/oidc-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class OidcProfileEndpoint extends CRUDExtend {
'GET',
undefined,
token,
undefined,
this,
headers
)
Expand All @@ -43,7 +42,6 @@ class OidcProfileEndpoint extends CRUDExtend {
'GET',
undefined,
token,
undefined,
this,
headers
)
Expand Down
1 change: 0 additions & 1 deletion src/endpoints/price-book-prices.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class PriceBookPricesEndpoint {
'GET',
undefined,
token,
undefined,
this
)
}
Expand Down
2 changes: 0 additions & 2 deletions src/extends/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class BaseExtend {
'GET',
undefined,
token,
undefined,
this
)

Expand All @@ -36,7 +35,6 @@ class BaseExtend {
'GET',
undefined,
token,
undefined,
this
)

Expand Down
19 changes: 10 additions & 9 deletions src/factories/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ class RequestFactory {
uri,
method,
body = undefined,
customerToken = undefined,
accountToken = undefined,
instance,
token = undefined,
instance = undefined,
wrapBody = true,
version = null
version = null,
additionalHeaders = undefined
) {
const { config, storage } = this

Expand Down Expand Up @@ -122,17 +122,18 @@ class RequestFactory {
headers['X-MOLTIN-LANGUAGE'] = config.language
}

if (customerToken) {
headers['X-MOLTIN-CUSTOMER-TOKEN'] = customerToken
}
if (accountToken) {
headers['EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN'] = accountToken
if (token) {
headers['X-MOLTIN-CUSTOMER-TOKEN'] = token
}

if (config.headers) {
Object.assign(headers, config.headers)
}

if (additionalHeaders) {
Object.assign(headers, additionalHeaders)
}

fetch(
`${config.protocol}://${config.host}/${
version || config.version ? `${version || config.version}/` : ''
Expand Down

0 comments on commit 80de8eb

Please sign in to comment.