diff --git a/idhub/templates/idhub/user/credentials_request.html b/idhub/templates/idhub/user/credentials_request.html
index 6dc720d..698ece5 100644
--- a/idhub/templates/idhub/user/credentials_request.html
+++ b/idhub/templates/idhub/user/credentials_request.html
@@ -20,6 +20,7 @@
{% endif %}
+{% if form.if_credentials %}
-
+{% else %}
+
+
+ {% trans 'Sorry no there are credentials enabled' %}
+
+
+{% endif %}
{% endblock %}
diff --git a/idhub/user/forms.py b/idhub/user/forms.py
index ca7ed99..b418b54 100644
--- a/idhub/user/forms.py
+++ b/idhub/user/forms.py
@@ -86,6 +86,7 @@ class RequestCredentialForm(forms.Form):
self.user = kwargs.pop('user', None)
self.lang = kwargs.pop('lang', None)
self._domain = kwargs.pop('domain', None)
+ self.if_credentials = kwargs.pop('if_credentials', None)
super().__init__(*args, **kwargs)
self.fields['did'].choices = [
(x.did, x.label) for x in DID.objects.filter(user=self.user)
diff --git a/idhub/user/views.py b/idhub/user/views.py
index defebb2..6db3500 100644
--- a/idhub/user/views.py
+++ b/idhub/user/views.py
@@ -392,18 +392,26 @@ class CredentialsRequestView(MyWallet, FormView):
form_class = RequestCredentialForm
success_url = reverse_lazy('idhub:user_credentials')
- def get(self, request, *args, **kwargs):
- response = super().get(request, *args, **kwargs)
- if not cache.get("KEY_DIDS"):
- return redirect(reverse_lazy('idhub:user_waiting'))
+ def get(self, *args, **kwargs):
+ response = super().get(*args, **kwargs)
+ if not DID.objects.filter(user=self.request.user).exists():
+ return redirect(reverse_lazy('idhub:user_dids_new'))
+
return response
+
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
+ self.if_credentials = VerificableCredential.objects.filter(
+ user=self.request.user,
+ status=VerificableCredential.Status.ENABLED.value,
+ ).exists()
+
kwargs['user'] = self.request.user
kwargs['lang'] = self.request.LANGUAGE_CODE
domain = "{}://{}".format(self.request.scheme, self.request.get_host())
kwargs['domain'] = domain
+ kwargs['if_credentials'] = self.if_credentials
return kwargs
def form_valid(self, form):
@@ -433,17 +441,19 @@ class DemandAuthorizationView(MyWallet, FormView):
user=self.request.user,
status=VerificableCredential.Status.ENABLED.value,
).exists()
+
if not self.if_credentials and creds_enable:
return redirect(reverse_lazy('idhub:user_credentials_request'))
return response
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
- kwargs['user'] = self.request.user
self.if_credentials = VerificableCredential.objects.filter(
user=self.request.user,
status=VerificableCredential.Status.ISSUED.value,
).exists()
+
+ kwargs['user'] = self.request.user
kwargs['if_credentials'] = self.if_credentials
return kwargs