diff --git a/cookbook/helper/permission_helper.py b/cookbook/helper/permission_helper.py
index b26d5557..9970bfff 100644
--- a/cookbook/helper/permission_helper.py
+++ b/cookbook/helper/permission_helper.py
@@ -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!'))
diff --git a/cookbook/templates/index.html b/cookbook/templates/index.html
index c0d010d4..069b27bf 100644
--- a/cookbook/templates/index.html
+++ b/cookbook/templates/index.html
@@ -91,7 +91,7 @@
{% render_table recipes %}
{% else %}
- {% trans "Log in to view recipes" %}
+ {% trans "Log in to view recipes" %}
{% endif %}
diff --git a/cookbook/views/views.py b/cookbook/views/views.py
index b4fa37bd..224e1cc1 100644
--- a/cookbook/views/views.py
+++ b/cookbook/views/views.py
@@ -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)