diff --git a/server/api/urls.py b/server/api/urls.py index 69beea15..51835b5f 100644 --- a/server/api/urls.py +++ b/server/api/urls.py @@ -5,7 +5,7 @@ from graphene_django.views import GraphQLView from api.schema_public import schema -from core.views import PrivateGraphQLView +from core.views import PrivateGraphQLView, ConfirmationKeyView app_name = 'api' urlpatterns = [ @@ -17,5 +17,6 @@ if settings.DEBUG: urlpatterns += [url(r'^graphiql-public', csrf_exempt(GraphQLView.as_view(schema=schema, graphiql=True, pretty=True)))] urlpatterns += [url(r'^graphiql', csrf_exempt(PrivateGraphQLView.as_view(graphiql=True, pretty=True)))] + urlpatterns += [url(r'^confirmation', ConfirmationKeyDisplayView.as_view(), name='confirmation_key_display')] diff --git a/server/core/hep_client.py b/server/core/hep_client.py index 58a1fafd..6779b193 100644 --- a/server/core/hep_client.py +++ b/server/core/hep_client.py @@ -34,8 +34,7 @@ class HepClientUnauthorizedException(Exception): class HepClient: - URL = 'https://stage.hep-verlag.ch' - # URL = 'https://www.hep-verlag.ch' + URL = settings.HEP_URL WEBSITE_ID = 1 HEADERS = { 'accept': 'application/json', @@ -118,13 +117,14 @@ class HepClient: }) return response.json() - def customers_search(self, email): + def customers_search(self, admin_token, email): response = self._call("/rest/V1/customers/search?searchCriteria[filterGroups][0][filters][0][field]" - "=email&searchCriteria[filterGroups][0][filters][0][value]={}".format(email)) + "=email&searchCriteria[filterGroups][0][filters][0][value]={}".format(email), method='get', + additional_headers={'authorization': 'Bearer {}'.format(admin_token)}) json_data = response.json() - if len(json_data) > 0: - return json_data[0] + if len(json_data['items']) > 0: + return json_data['items'][0] return None def _customer_orders(self, admin_token, customer_id): diff --git a/server/core/settings.py b/server/core/settings.py index 86f66bb7..204cf128 100644 --- a/server/core/settings.py +++ b/server/core/settings.py @@ -374,5 +374,6 @@ USE_LOCAL_REGISTRATION = False # HEP HEP_ADMIN_USER = "adminuser" HEP_ADMIN_PASSWORD = "password" +HEP_URL = 'https://stage.hep-verlag.ch' diff --git a/server/core/templates/confirmation_key.html b/server/core/templates/confirmation_key.html new file mode 100644 index 00000000..876f9568 --- /dev/null +++ b/server/core/templates/confirmation_key.html @@ -0,0 +1,10 @@ + + +
+ +