fixed incorrect redirects for unauthenticated users
This commit is contained in:
parent
43ccc351c7
commit
320d94a223
@ -115,7 +115,7 @@ def group_required(*groups_required):
|
||||
def in_groups(u):
|
||||
return has_group_permission(u, groups_required)
|
||||
|
||||
return user_passes_test(in_groups, login_url='index')
|
||||
return user_passes_test(in_groups)
|
||||
|
||||
|
||||
class GroupRequiredMixin(object):
|
||||
@ -138,7 +138,7 @@ class OwnerRequiredMixin(object):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not request.user.is_authenticated:
|
||||
messages.add_message(request, messages.ERROR, _('You are not logged in and therefore cannot view this page!'))
|
||||
return HttpResponseRedirect(reverse_lazy('login'))
|
||||
return HttpResponseRedirect(reverse_lazy('login') + '?next=' + request.path)
|
||||
else:
|
||||
if not is_object_owner(request.user, self.get_object()):
|
||||
messages.add_message(request, messages.ERROR, _('You cannot interact with this object as it is not owned by you!'))
|
||||
|
@ -91,7 +91,7 @@
|
||||
{% render_table recipes %}
|
||||
{% else %}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
{% trans "Log in to view recipes" %}
|
||||
{% trans "Log in to view recipes" %} <br/>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@ -10,7 +10,7 @@ from django.core.exceptions import ValidationError
|
||||
from django.db.models import Q, Avg
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.urls import reverse
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils import timezone
|
||||
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
from django_tables2 import RequestConfig
|
||||
@ -41,7 +41,7 @@ def index(request):
|
||||
|
||||
return HttpResponseRedirect(page_map.get(request.user.userpreference.default_page))
|
||||
except UserPreference.DoesNotExist:
|
||||
return HttpResponseRedirect(reverse_lazy('view_search'))
|
||||
return HttpResponseRedirect(reverse('login') + '?next=' + request.path)
|
||||
|
||||
|
||||
def search(request):
|
||||
@ -70,7 +70,7 @@ def search(request):
|
||||
|
||||
return render(request, 'index.html', {'recipes': table, 'filter': f, 'last_viewed': last_viewed})
|
||||
else:
|
||||
return render(request, 'index.html')
|
||||
return HttpResponseRedirect(reverse('login') + '?next=' + request.path)
|
||||
|
||||
|
||||
def recipe_view(request, pk, share=None):
|
||||
@ -78,7 +78,7 @@ def recipe_view(request, pk, share=None):
|
||||
|
||||
if not request.user.is_authenticated and not share_link_valid(recipe, share):
|
||||
messages.add_message(request, messages.ERROR, _('You do not have the required permissions to view this page!'))
|
||||
return HttpResponseRedirect(reverse('index'))
|
||||
return HttpResponseRedirect(reverse('login') + '?next=' + request.path)
|
||||
|
||||
comments = Comment.objects.filter(recipe=recipe)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user