logged in users can't see the /login and /signup pages

This commit is contained in:
iou1name 2018-08-12 01:59:22 -04:00
parent 7fb52374f9
commit 03ba297122
3 changed files with 12 additions and 2 deletions

View File

@ -3,8 +3,11 @@
{% block content %} {% block content %}
<h1>Quests 'n Shiet</h1> <h1>Quests 'n Shiet</h1>
<a href="./quest/1">Unga Bunga Quest</a><br /> <a href="./quest/1">Unga Bunga Quest</a><br />
{% if request.user.is_authenticated %}
<a href="{{ url('create_quest:index') }}">Create New Quest</a><br /> <a href="{{ url('create_quest:index') }}">Create New Quest</a><br />
<a href="{{ url('logout:index') }}">Logout</a><br />
{% else %}
<a href="{{ url('signup:index') }}">Sign up</a><br /> <a href="{{ url('signup:index') }}">Sign up</a><br />
<a href="{{ url('login:index') }}">Login</a><br /> <a href="{{ url('login:index') }}">Login</a><br />
<a href="{{ url('logout:index') }}">Logout</a><br /> {% endif %}
{% endblock %} {% endblock %}

View File

@ -12,6 +12,8 @@ def index(request):
""" """
The login page. The login page.
""" """
if request.user.is_authenticated:
return redirect('homepage:index')
if request.method == "GET": if request.method == "GET":
form = LoginForm() form = LoginForm()
return render(request, 'login/index.html', {'form': form}) return render(request, 'login/index.html', {'form': form})

View File

@ -2,12 +2,17 @@
""" """
/signup app views. /signup app views.
""" """
from django.shortcuts import render from django.shortcuts import redirect, render
from users.models import User
def index(request): def index(request):
""" """
The signup page. The signup page.
""" """
if request.user.is_authenticated:
return redirect('homepage:index')
if request.method == "GET": if request.method == "GET":
context = {} context = {}
return render(request, 'signup/index.html', context) return render(request, 'signup/index.html', context)