Files
training.django/source/authentication/users/views.py
Steve Kossouho e3ebf6bf4f Add documentation and source
Added documentation, source and extra files.
2025-07-02 20:26:50 +02:00

23 lines
721 B
Python

from annoying.decorators import render_to
from django.contrib.auth import login, logout, authenticate
@render_to("users/user-page.html")
def view_user(request):
return {}
@render_to("users/user-code-page.html")
def view_authentication_code(request):
# First, logout if we're already connected
logout(request)
# Show that we have no connected user session for the request
print(request.user)
# Check authentication with the current settings
user = authenticate(username="root", password="root")
# A user is returned only if the credentials are correct
if user is not None:
# Login the obtained user in the request
login(request, user)
return {"auth_user": user}