Take user to logged in page when already authenticated

This commit is contained in:
PCoder 2019-02-24 20:14:49 +01:00
parent c3b8f7b553
commit f61023d01a

View file

@ -8,6 +8,7 @@ from django.core.validators import validate_email, ValidationError
from django.urls import reverse_lazy
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.core.mail import EmailMessage
from django.views.decorators.cache import cache_control
from .models import ResetToken
from .forms import LoginForm
from .ungleich_ldap import LdapManager
@ -44,6 +45,14 @@ class Index(FormView):
return render(self.request, 'useroptions.html', { 'user': user } )
return render(self.request, 'loginfailed.html')
@cache_control(no_cache=True, must_revalidate=True, no_store=True)
def get(self, request, *args, **kwargs):
if self.request.user.is_authenticated:
return render(self.request, 'useroptions.html',
{ 'user': self.request.user.username } )
return super(Index, self).get(request, *args, **kwargs)
class Register(View):
def get(self, request):
return render(request, 'registeruser.html')