Add documentation and source
Added documentation, source and extra files.
This commit is contained in:
9
source/authentication/users/__init__.py
Normal file
9
source/authentication/users/__init__.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class UsersConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "users"
|
||||
|
||||
|
||||
default_app_config = "users.UsersConfig"
|
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="" method="post" name="login-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" name="login-button" value="Login">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>User</title>
|
||||
</head>
|
||||
<body>
|
||||
{% if user.is_anonymous %}
|
||||
You are not connected with a user.
|
||||
{% else %}
|
||||
Welcome, you are connected as {{ user.username }}
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
14
source/authentication/users/templates/users/user-page.html
Normal file
14
source/authentication/users/templates/users/user-page.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>User</title>
|
||||
</head>
|
||||
<body>
|
||||
{% if user.is_anonymous %}
|
||||
You are not connected with a user.
|
||||
{% else %}
|
||||
Welcome, you are connected as {{ user.username }}
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
22
source/authentication/users/views.py
Normal file
22
source/authentication/users/views.py
Normal file
@ -0,0 +1,22 @@
|
||||
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}
|
Reference in New Issue
Block a user