Fix email verification for stage
This commit is contained in:
parent
82c1135f0e
commit
909f7337ac
|
|
@ -38,21 +38,22 @@ export default {
|
|||
mounted() {
|
||||
this.$apollo.mutate({
|
||||
mutation: REGISTRATION_MUTATION,
|
||||
client: 'publicClient',
|
||||
variables: {
|
||||
input: {
|
||||
confirmationKeyInput: this.$route.query.confirmation || ''
|
||||
}
|
||||
},
|
||||
fetchPolicy: 'no-cache'
|
||||
}).then(({data: {registration}}) => {
|
||||
}).then(data => {
|
||||
|
||||
this.loading = false;
|
||||
|
||||
if (registration.success) {
|
||||
if (data.registration.success) {
|
||||
this.keyValid = true;
|
||||
this.$router.push('/');
|
||||
} else {
|
||||
switch (registration.errors[0].field) {
|
||||
switch (data.registration.errors[0].field) {
|
||||
case 'invalid_key':
|
||||
this.errorMessage = 'Der angegebene Verifizierungscode ist falsch oder abgelaufen.';
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class HepClient:
|
|||
def fetch_admin_token(self, admin_user, password):
|
||||
response = self._call('/rest/deutsch/V1/integration/admin/token', 'post',
|
||||
data={'username': admin_user, 'password': password})
|
||||
return response.json()['token']
|
||||
return response.content.decode('utf-8')[1:-1]
|
||||
|
||||
def is_email_available(self, email):
|
||||
response = self._call('/rest/deutsch/V1/customers/isEmailAvailable', method='post',
|
||||
|
|
@ -112,14 +112,14 @@ class HepClient:
|
|||
return response.json()
|
||||
|
||||
def customer_activate(self, confirmation_key):
|
||||
response = self._call('/rest/V1/customers/me/activate', method='post', data={
|
||||
response = self._call("/customer/account/confirm/?back_url=&id=58862&key=f62319366a5ecdd1e3dede5fd1a5c236", method='put', data={
|
||||
'confirmationKey': confirmation_key
|
||||
})
|
||||
return response.json()
|
||||
|
||||
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), method='get',
|
||||
response = self._call("/rest/V1/customers/search?searchCriteria[filterGroups][0][filters][0][field]="
|
||||
"email&searchCriteria[filterGroups][0][filters][0][value]={}".format(email), method='get',
|
||||
additional_headers={'authorization': 'Bearer {}'.format(admin_token)})
|
||||
|
||||
json_data = response.json()
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
# Created on 03.02.20
|
||||
# @author: chrigu <christian.cueni@iterativ.ch>
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
|
||||
from core.hep_client import HepClient
|
||||
|
||||
|
|
@ -33,6 +33,8 @@ class AdminDataManager(models.Manager):
|
|||
|
||||
try:
|
||||
admin_token = self.get(pk=DEFAULT_PK)
|
||||
if admin_token.updated_at < timezone.now() + timedelta(hours=1):
|
||||
admin_token = self.update_admin_token()
|
||||
except self.model.DoesNotExist:
|
||||
admin_token = self.update_admin_token()
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@
|
|||
<title>Confirmation</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="/{{ confirmation_key }}">Email bestätitgen</a>
|
||||
<a href="/verify-email?confirmation={{ confirmation_key }}&id={{ hep_id }}">Email bestätitgen</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ class ConfirmationKeyDisplayView(TemplateView):
|
|||
admin_token = AdminData.objects.get_admin_token()
|
||||
hep_user = hep_client.customers_search(admin_token, email)
|
||||
|
||||
context = super().get_context_data(self.request, **kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['confirmation_key'] = hep_user['confirmation']
|
||||
context['hep_id'] = hep_user['id']
|
||||
return context
|
||||
|
|
|
|||
Loading…
Reference in New Issue