fix that you could not see the token in dark mode.

This commit is contained in:
2025-10-23 18:12:51 +02:00
parent 2b25ad30af
commit a3ffde3206
4 changed files with 21 additions and 21 deletions

View File

@@ -1,8 +1,9 @@
import logging import logging
from django.shortcuts import render
from authentications.decorators import authenticated_user
from django.conf import settings
from django.conf import settings
from django.shortcuts import render
from authentications.decorators import authenticated_user
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -10,21 +11,18 @@ logger = logging.getLogger(__name__)
# Function that generates a token depending on unsername and masterpassword # Function that generates a token depending on unsername and masterpassword
# The masterpassword must be 32 characters long! # The masterpassword must be 32 characters long!
def create_token(username, masterpassword): def create_token(username, masterpassword):
padded_username = username.ljust(32, ":")
padded_username = username.ljust(32, ':')
token = bytearray() token = bytearray()
# xor connect with masterpassword to create token # xor connect with masterpassword to create token
for i in range(32): for i in range(32):
token.append(ord(padded_username[i]) ^ ord(masterpassword[i])) token.append(ord(padded_username[i]) ^ ord(masterpassword[i]))
str_token = token.hex() return token.hex()
return str_token
@authenticated_user @authenticated_user
def index(request): def index(request):
username = request.user
context = { context = {
"mctoken": "", "mctoken": "",
"valid_master_pwd": True "valid_master_pwd": True
@@ -36,7 +34,7 @@ def index(request):
context["valid_master_pwd"] = False context["valid_master_pwd"] = False
logger.error("Masterpassword must be 32 characters long") logger.error("Masterpassword must be 32 characters long")
else: else:
token = create_token(str(username), masterpassword) token = create_token(str(request.user), masterpassword)
context["mctoken"] = token context["mctoken"] = token
return render(request, "minecraft/index.html", context) return render(request, "minecraft/index.html", context)

View File

@@ -9,13 +9,15 @@
<div class="container mx-auto w-full px-4 my-8 flex-1"> <div class="container mx-auto w-full px-4 my-8 flex-1">
<h1 class="page-title">Minecraft</h1> <h1 class="page-title">Minecraft</h1>
{% if valid_master_pwd %} <div class="flex flex-col gap-y-8 max-w-prose mx-auto text-gray-700 dark:text-gray-300">
<h2>Dein persömlicher Token für den Minecraft-Server:</h2>
<p>{{ mctoken }}</p> {% if not valid_master_pwd %}
<p>Dein persönlicher Token für den Minecraft-Server: {{ mctoken }}</p>
{% else %} {% else %}
<h2>Ups... Das hat nicht geklappt!</h2> <p>Ups... Das hat nicht geklappt! Bitte informiere einen Admin!</p>
<p>Bitte informiere einen Admin!</p>
{% endif %} {% endif %}
</div>
</div> </div>
</main> </main>
{% endblock %} {% endblock content %}