🔒 Repository is read-only – file editing is disabled.

PaganLinux/pagan-web-v2/templates/profile/index.html main

64 linii Raw ← Powrót
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
{% extends "base.html" %}{% block title %}{{ t('profile') }}{% endblock %}
{% block content %}<div class="card" style="max-width:550px;margin:2rem auto"><div class="card-header"><h2> {{ t('profile') }}: {{ user.username }}</h2></div>

{% if generated_token %}<div class="flash flash-ok"> Token: <code style="word-break:break-all">{{ generated_token }}</code><br><small>Zapisz go! Nie będzie ponownie wyświetlony.</small></div>{% endif %}

<h3 style="margin-top:1rem"> {{ t('email') }}</h3>
<form method="POST"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
 <input type="hidden" name="action" value="email">
 <div style="display:flex;gap:0.5rem"><input name="email" value="{{ user.email or '' }}" style="flex:1;padding:0.5rem;background:#0d1117;border:1px solid var(--border);color:#fff;border-radius:var(--radius-sm)"><button class="btn btn-primary">{{ t('save') }}</button></div>
</form>

<h3 style="margin-top:1.5rem"> {{ t('change_password') }}</h3>
<form method="POST"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
 <input type="hidden" name="action" value="password">
 <input type="password" name="current_password" placeholder="{{ t('current_password') }}" style="width:100%;padding:0.5rem;margin-bottom:0.5rem;background:#0d1117;border:1px solid var(--border);color:#fff;border-radius:var(--radius-sm)" required>
 <input type="password" name="new_password" placeholder="{{ t('new_password') }} (min. 5)" style="width:100%;padding:0.5rem;margin-bottom:0.5rem;background:#0d1117;border:1px solid var(--border);color:#fff;border-radius:var(--radius-sm)" required>
 {% if totp_enabled %}<input name="2fa_code" placeholder="Kod 2FA (6 cyfr)" maxlength="6" pattern="[0-9]{6}" style="width:100%;max-width:150px;padding:0.5rem;margin-bottom:0.5rem;background:#0d1117;border:1px solid var(--border);color:#fff;border-radius:var(--radius-sm);text-align:center;letter-spacing:0.3em">{% endif %}
 <button class="btn btn-primary">{{ t('save') }}</button>
</form>

<h3 style="margin-top:1.5rem"> {{ t('token') }}</h3>
<p class="text-muted" style="font-size:0.85rem">{{ t('token_help') }}</p>
<form method="POST"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
 <input type="hidden" name="action" value="token">
 {% if totp_enabled %}<input name="2fa_code" placeholder="Kod 2FA (6 cyfr)" maxlength="6" pattern="[0-9]{6}" style="width:100%;max-width:150px;padding:0.5rem;margin-bottom:0.5rem;background:#0d1117;border:1px solid var(--border);color:#fff;border-radius:var(--radius-sm);text-align:center;letter-spacing:0.3em">{% endif %}
 <button class="btn btn-primary">{{ t('generate_token') }}</button>
</form>

<h3 style="margin-top:1.5rem"> 2FA</h3>
{% if totp_enabled %}
<p class="text-muted" style="font-size:0.85rem;color:#3fb950">✅ 2FA {{ t('admin_pagsync_running') }}.</p>
<form method="POST" onsubmit="return confirm('Wyłączyć 2FA?')">
 <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
 <input type="hidden" name="action" value="disable_2fa">
 <input type="password" name="current_password" placeholder="{{ t('current_password') }}" style="width:100%;max-width:250px;padding:0.5rem;margin-bottom:0.5rem;background:#0d1117;border:1px solid var(--border);color:#fff;border-radius:var(--radius-sm)" required>
 <button class="btn btn-danger"> Wyłącz 2FA</button>
</form>
{% elif setup_2fa and user.totp_secret %}
<p class="text-muted" style="font-size:0.85rem">Zeskanuj kod QR lub otwórz link w aplikacji 2FA:</p>
<div style="background:var(--bg2);border:1px solid var(--border);padding:0.75rem;border-radius:var(--radius-sm);margin-bottom:0.5rem;text-align:center">
 <img src="https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=otpauth://totp/PaganOS:{{ user.username }}?secret={{ user.totp_secret }}&issuer=PaganOS" alt="QR" style="max-width:200px;border-radius:8px;background:#fff;padding:8px" onerror="this.style.display='none';document.getElementById('qrfail').style.display='block'">
 <div id="qrfail" style="display:none;margin-top:0.5rem"><p class="text-muted">Nie można załadować QR. Wpisz klucz ręcznie:</p></div>
 <div style="margin-top:0.75rem">
 <code style="word-break:break-all;font-size:0.8rem;background:var(--bg);border:1px solid var(--border);color:var(--text);padding:0.4rem 0.6rem;border-radius:4px;user-select:all">{{ user.totp_secret }}</code>
 <div style="margin-top:0.4rem"><a href="otpauth://totp/PaganOS:{{ user.username }}?secret={{ user.totp_secret }}&issuer=PaganOS" class="btn btn-sm" style="font-size:0.7rem"> Otwórz w aplikacji</a></div>
 </div>
</div>
<form method="POST">
 <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
 <input type="hidden" name="action" value="verify_2fa">
 <div style="display:flex;gap:0.5rem;align-items:center">
 <input name="code" placeholder="000000" maxlength="6" pattern="[0-9]{6}" style="width:120px;padding:0.5rem;background:#0d1117;border:1px solid var(--border);color:#fff;border-radius:var(--radius-sm);font-size:1.1rem;text-align:center;letter-spacing:0.3em" required autofocus>
 <button class="btn btn-primary">✅ Zweryfikuj</button>
 </div>
</form>
{% else %}
<p class="text-muted" style="font-size:0.85rem">Dodaj dodatkową warstwę zabezpieczeń. Po włączeniu, przy logowaniu będziesz podawać kod z aplikacji 2FA.</p>
<form method="POST">
 <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
 <input type="hidden" name="action" value="setup_2fa">
 <button class="btn" style="background:var(--accent2);color:#fff;border:none"> Włącz 2FA</button>
</form>
{% endif %}
</div>{% endblock %}