Skip to content
Snippets Groups Projects
Commit ec3f79c1 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

after login redirection is handled properly

parent b7211766
No related branches found
No related tags found
1 merge request!9Resolve "Redirect after logging in"
......@@ -75,6 +75,9 @@
<form action="{% url 'web.views.login' %}" method="post">
{% csrf_token %}
{% if next %}
<input type="hidden" name="next" value="{{ next }}" />
{% endif %}
<div class="form-group has-feedback">
<input type="text" name="username" class="form-control" placeholder="Login">
......
......@@ -54,13 +54,18 @@ def login(request):
if request.GET and request.GET.get('error'):
context['state'] = request.GET.get('error')
if request.method == "GET" and request.GET:
context['next'] = request.GET.get('next')
if request.method == "POST" and request.POST:
state, message = do_login(request)
if state == True:
return redirect(appointments)
if request.POST.get('next'):
return redirect(request.POST.get('next'))
else:
return redirect(appointments)
else:
return redirect('/login?error=' + message)
return render(request, "login.html", context)
class NotificationCount(object):
......@@ -84,6 +89,9 @@ def get_filter_locations(user):
worker = workers[0]
elif isinstance(user, Worker):
worker = user
elif isinstance(user, AnonymousUser):
# anonymous user shouldn't see anything
return Location.objects.filter(id=-1)
elif user!=None:
raise TypeError("Unknown class type: "+user.__class__.__name__)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment