stages/otp_static: fix redirect URL after setup, fix stage not being passed to setup

This commit is contained in:
Jens Langhammer 2020-09-25 19:38:51 +02:00
parent 74d3cfbba0
commit 4ee22f8ec1
4 changed files with 7 additions and 4 deletions

View file

@ -11,7 +11,7 @@ class OTPStaticStageSerializer(ModelSerializer):
class Meta:
model = OTPStaticStage
fields = ["pk", "name", "token_count"]
fields = ["pk", "name", "configure_flow", "token_count"]
class OTPStaticStageViewSet(ModelViewSet):

View file

@ -32,7 +32,7 @@ class OTPStaticStageForm(forms.ModelForm):
class Meta:
model = OTPStaticStage
fields = ["name", "token_count"]
fields = ["name", "configure_flow", "token_count"]
widgets = {
"name": forms.TextInput(),

View file

@ -26,7 +26,7 @@
</ul>
{% if not state %}
{% if stage.configure_flow %}
<a href="{% url 'passbook_flows:configure' stage_uuid=stage.stage_uuid %}" class="pf-c-button pf-m-primary">{% trans "Enable Static Tokens" %}</a>
<a href="{% url 'passbook_flows:configure' stage_uuid=stage.stage_uuid %}?next={{ request.get_full_path }}" class="pf-c-button pf-m-primary">{% trans "Enable Static Tokens" %}</a>
{% endif %}
{% else %}
<a href="{% url 'passbook_stages_otp_static:disable' stage_uuid=stage.stage_uuid %}" class="pf-c-button pf-m-danger">{% trans "Disable Static Tokens" %}</a>

View file

@ -2,12 +2,13 @@
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect
from django.shortcuts import get_object_or_404, redirect
from django.views import View
from django.views.generic import TemplateView
from django_otp.plugins.otp_static.models import StaticDevice, StaticToken
from passbook.audit.models import Event
from passbook.stages.otp_static.models import OTPStaticStage
class UserSettingsView(LoginRequiredMixin, TemplateView):
@ -18,6 +19,8 @@ class UserSettingsView(LoginRequiredMixin, TemplateView):
# TODO: Check if OTP Stage exists and applies to user
def get_context_data(self, **kwargs):
kwargs = super().get_context_data(**kwargs)
stage = get_object_or_404(OTPStaticStage, pk=self.kwargs["stage_uuid"])
kwargs["stage"] = stage
static_devices = StaticDevice.objects.filter(
user=self.request.user, confirmed=True
)