Working .env setup

This commit is contained in:
2026-08-03 10:39:19 -05:00
parent f593d16ca4
commit 2764644d8b
19 changed files with 546 additions and 66 deletions
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Packs Site - Restricted{% endblock %}</title>
{% load static %}
<link rel="stylesheet" href="{% static 'css/style.css' %}">
<link rel="icon" type="image/png" href="{% static 'Logo.png' %}">
</head>
<body>
<main class="gate-main">
<div class="gate-card">
<img src="{% static 'Logo.png' %}" alt="Packs" height="64">
<h1>Restricted Access</h1>
<p>This site is private. Enter the master password to continue.</p>
{% if error %}
<p class="gate-error">{{ error }}</p>
{% endif %}
<form method="post" action="{% url 'landing:gate' %}">
{% csrf_token %}
<input type="password" name="password" placeholder="Master password" autofocus required>
<button type="submit">Enter</button>
</form>
</div>
</main>
</body>
</html>
@@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% block title %}Home - Packs{% endblock %}
{% block content %}
<h1>Welcome</h1>
<p>Pack library and download area will live here.</p>
{% endblock %}
+10
View File
@@ -0,0 +1,10 @@
from django.urls import path
from . import views
app_name = 'landing'
urlpatterns = [
path('', views.gate, name='gate'),
path('home/', views.home, name='home'),
]
+49 -2
View File
@@ -1,3 +1,50 @@
from django.shortcuts import render
import hmac
import random
import time
# Create your views here.
from django.conf import settings
from django.shortcuts import redirect, render
from common.middleware import gate_whitelist
def _under_lockout(request):
lock_until = request.session.get('lock_until')
if lock_until and time.time() < lock_until:
return True
return False
def _start_lockout(request):
duration = random.randint(30, 300)
request.session['lock_until'] = time.time() + duration
@gate_whitelist
def gate(request):
if request.method == 'POST':
if _under_lockout(request):
return render(request, 'landing/gate.html', {
'error': 'Incorrect password.',
})
submitted = request.POST.get('password', '')
master = settings.PASSWORD or ''
if hmac.compare_digest(submitted, master):
request.session['authorized'] = True
request.session.pop('lock_until', None)
return redirect('home')
else:
_start_lockout(request)
return render(request, 'landing/gate.html', {
'error': 'Incorrect password.',
})
if request.session.get('authorized'):
return redirect('home')
return render(request, 'landing/gate.html')
def home(request):
return render(request, 'landing/home.html')