Files
2026-09-01 10:46:29 -03:00

107 lines
4.9 KiB
Twig
Executable File

{% extends "layouts/base.twig" %}
{% block title %}{{ __('auth.forgot_password_title', {'platformName': platformName}) }}{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-lg-5">
<div class="card shadow-lg border-0 rounded-lg mt-5">
<div class="card-header">
<h3 class="text-center font-weight-light my-4">
{{ __('auth.forgot_password_title', {'platformName': platformName}) }}
</h3>
</div>
<div class="card-body p-4">
{% if error %}
<div class="alert alert-danger" role="alert">
{{ error == 1 ? __('auth.email_not_found') : '' }}
{{ error == 'captcha' ? __('auth.invalid_captcha') : '' }}
{{ error == 'rate' ? __('auth.too_many_attempts') : '' }}
</div>
{% endif %}
{% if success %}
<div class="alert alert-success" role="alert">
{{ __('auth.reset_link_sent') }}
</div>
{% endif %}
<form method="POST" action="{{ url('forgot-password') }}">
{{ csrf_field() }}
<div class="form-floating mb-3">
<input type="email" class="form-control" id="email" name="email" placeholder="{{ __('auth.email_placeholder') }}" required>
<label for="email">{{ __('auth.email') }}</label>
</div>
{% if require_captcha_forgot %}
<div class="mb-3" x-data="{
num1: 0,
num2: 0,
userAnswer: '',
solved: false,
generate() {
this.num1 = Math.floor(Math.random() * 10) + 1;
this.num2 = Math.floor(Math.random() * 10) + 1;
this.userAnswer = '';
this.solved = false;
},
check() {
if (parseInt(this.userAnswer) === (this.num1 + this.num2)) {
this.solved = true;
} else {
this.solved = false;
}
}
}" x-init="generate()">
<div class="mb-3">
<label class="form-label fw-bold mb-2">{{ __('auth.security_check') }}</label>
<div class="d-flex align-items-center gap-2">
<div class="px-3 py-2 bg-white border rounded fw-bold fs-5 text-nowrap">
<span x-text="num1"></span> + <span x-text="num2"></span> =
</div>
<input type="number" class="form-control" style="width: 80px;" x-model="userAnswer" @input="check()" placeholder="?">
<button type="button" class="btn btn-outline-secondary btn-sm ms-1" @click="generate()" title="{{ __('auth.captcha_reload') }}">
<i class="bi bi-arrow-clockwise"></i> ↻
</button>
</div>
<div class="mt-2" style="min-height: 24px;">
<span x-show="solved" class="text-success fw-bold small">
✓ {{ __('auth.captcha_solved') }}
</span>
<span x-show="!solved" class="text-muted small">
{{ __('auth.captcha_instruction') }}
</span>
</div>
</div>
<input type="hidden" name="captcha_valid" :value="solved ? '1' : ''">
</div>
{% endif %}
<div class="d-grid">
<button class="btn btn-primary" type="submit">
{{ __('auth.send_reset_link') }}
</button>
<a href="{{ url('login') }}" class="btn btn-link">
{{ __('auth.back_to_login') }}
</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
// Auto-focus on email field
document.addEventListener('DOMContentLoaded', function() {
const emailField = document.getElementById('email');
if (emailField) {
emailField.focus();
}
});
</script>
{% endblock %}