Ready For 1.1

This commit is contained in:
nocci 2025-05-10 16:14:22 +02:00
parent c23f2f88e8
commit 7a221acb8e
11 changed files with 297 additions and 146 deletions

View file

@ -72,6 +72,7 @@ from sqlalchemy.engine import Engine
from sqlalchemy.exc import IntegrityError, LegacyAPIWarning
from sqlalchemy.orm import joinedload
from werkzeug.security import check_password_hash, generate_password_hash
from werkzeug.middleware.proxy_fix import ProxyFix
from wtforms import SelectField, StringField, TextAreaField, validators
# Config
@ -100,6 +101,11 @@ app.jinja_env.globals['getattr'] = getattr
def not_found_error(error):
return render_template('404.html'), 404
app.wsgi_app = ProxyFix(
app.wsgi_app,
x_proto=1, # Trust X-Forwarded-Proto Header
x_host=1 # Trust X-Forwarded-Host Header
)
# UNIX-Systems (Linux, Docker)
try:
@ -981,7 +987,7 @@ def generate_redeem(game_id):
)
db.session.add(new_token)
db.session.commit()
redeem_url = url_for('redeem', token=token, _external=True)
redeem_url = url_for('redeem', token=token, _external=True, _scheme='https')
message = translate(
'Redeem link generated: <a href="{url}" target="_blank">{url}</a>',
url=redeem_url
@ -1005,22 +1011,25 @@ def redeem_page(token):
redeem_token.used = True
db.session.commit()
# which Plattform
if game.platform == "steam" or game.steam_appid:
if game.platform == 'steam':
platform_link = 'https://store.steampowered.com/account/registerkey?key='
platform_label = "Steam"
elif game.platform == "gog":
platform_name = 'Steam'
elif game.platform == 'gog':
platform_link = 'https://www.gog.com/redeem/'
platform_label = "GOG"
elif game.platform == "xbox":
platform_name = 'GOG'
elif game.platform == 'xbox':
platform_link = 'https://redeem.microsoft.com/'
platform_label = "XBOX"
elif game.platform == "playstation":
platform_link = 'https://store.playstation.com/redeem'
platform_label = "PlayStation"
platform_name = 'Xbox'
elif game.platform == 'playstation':
platform_link = 'https://redeem.playstation.com/'
platform_name = 'PlayStation'
elif game.platform == 'switch':
platform_link = 'https://ec.nintendo.com/redeem/'
platform_name = 'Nintendo Switch'
else:
platform_link = '#'
platform_label = game.platform.capitalize() if game.platform else "Unknown"
# Fallback für benutzerdefinierte Keys
platform_link = ''
platform_name = 'Key'
return render_template(
'redeem.html',
@ -1028,9 +1037,10 @@ def redeem_page(token):
redeem_token=redeem_token,
expires_timestamp=int(expires_utc.timestamp() * 1000),
platform_link=platform_link,
platform_label=platform_label
platform_name=platform_name
)
@app.route('/admin/users')
@login_required
@admin_required