<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
use Twig\TemplateWrapper;
/* registration/register.html.twig */
class __TwigTemplate_ba606fe98b6df081002b2e6f09b9c601 extends Template
{
private Source $source;
/**
* @var array<string, Template>
*/
private array $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->blocks = [
'title' => [$this, 'block_title'],
'body' => [$this, 'block_body'],
'javascripts' => [$this, 'block_javascripts'],
];
}
protected function doGetParent(array $context): bool|string|Template|TemplateWrapper
{
// line 1
return "base_home.html.twig";
}
protected function doDisplay(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
$__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "registration/register.html.twig"));
$__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "registration/register.html.twig"));
$this->parent = $this->load("base_home.html.twig", 1);
yield from $this->parent->unwrap()->yield($context, array_merge($this->blocks, $blocks));
$__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
}
// line 3
/**
* @return iterable<null|scalar|\Stringable>
*/
public function block_title(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
$__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "title"));
$__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "title"));
yield "Inscription | MaketOu";
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
$__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
yield from [];
}
// line 5
/**
* @return iterable<null|scalar|\Stringable>
*/
public function block_body(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
$__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "body"));
$__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "body"));
// line 6
yield "
<!-- Start Banner Area -->
<section class=\"banner-area organic-breadcrumb\">
<div class=\"container\">
<div class=\"breadcrumb-banner d-flex flex-wrap align-items-center justify-content-end\">
<div class=\"col-first\">
<h1>Inscription</h1>
<nav class=\"d-flex align-items-center\">
<a href=\"";
// line 14
yield $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("ui_home");
yield "\">Accueil<span class=\"lnr lnr-arrow-right\"></span></a>
<a href=\"javascript:void(0)\">Inscription</a>
</nav>
</div>
</div>
</div>
</section>
<!-- End Banner Area -->
";
// line 23
$context['_parent'] = $context;
$context['_seq'] = CoreExtension::ensureTraversable(CoreExtension::getAttribute($this->env, $this->source, ($context["app"] ?? null), "flashes", ["verify_email_error"], "method", false, false, false, 23));
foreach ($context['_seq'] as $context["_key"] => $context["flash_error"]) {
// line 24
yield " <div class=\"alert alert-danger\" role=\"alert\">";
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($context["flash_error"], "html", null, true);
yield "</div>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_key'], $context['flash_error'], $context['_parent']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 26
yield "
";
// line 27
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(($context["registrationForm"] ?? null), 'errors');
yield "
<!--================Login Box Area =================-->
<section class=\"login_box_area section_gap\">
<div class=\"container\">
<div class=\"row\">
<div class=\"col-lg-6\">
<div class=\"login_box_img\">
<img class=\"img-fluid\" src=\"";
// line 36
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl("ui/img/login.jpg"), "html", null, true);
yield "\" alt=\"\">
<div class=\"hover\">
<h4>Vous avez un compte?</h4>
<p>Connectez-vous à votre compte pour accéder à vos commandes, suivre vos livraisons et gérer vos préférences personnelles.</p>
<a class=\"primary-btn\" href=\"";
// line 40
yield $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("ui_app_login");
yield "\">Se connecter</a>
</div>
</div>
</div>
<div class=\"col-lg-6\">
<div class=\"login_form_inner\">
<h3>S'inscrire</h3>
";
// line 48
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->renderBlock(($context["registrationForm"] ?? null), 'form_start', ["attr" => ["class" => "needs-validation row login_form"]]);
yield "
";
// line 49
if ((($tmp = CoreExtension::getAttribute($this->env, $this->source, ($context["app"] ?? null), "user", [], "any", false, false, false, 49)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
// line 50
yield " <div class=\"mb-3\">
Vous êtes connecté comme ";
// line 51
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, ($context["app"] ?? null), "user", [], "any", false, false, false, 51), "userIdentifier", [], "any", false, false, false, 51), "html", null, true);
yield ", <a
href=\"";
// line 52
yield $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("ui_app_logout");
yield "\">Déconnexion</a>
</div>
";
}
// line 55
yield "
<div class=\"col-md-12 form-group\">
";
// line 57
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["registrationForm"] ?? null), "email", [], "any", false, false, false, 57), 'label', ["label_attr" => ["class" => "form-label"], "label" => "Email"]);
yield "
";
// line 58
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["registrationForm"] ?? null), "email", [], "any", false, false, false, 58), 'widget', ["attr" => ["class" => "form-control", "placeholder" => "email@example.com", "onfocus" => "this.placeholder = ''", "onblur" => "this.placeholder = 'email@example.com'", "id" => "registration_email"]]);
yield "
";
// line 59
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["registrationForm"] ?? null), "email", [], "any", false, false, false, 59), 'errors');
yield "
<small class=\"form-text text-muted email-validation-message\"></small>
</div>
<div class=\"col-md-12 form-group\">
";
// line 63
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["registrationForm"] ?? null), "plainPassword", [], "any", false, false, false, 63), 'label', ["label_attr" => ["class" => "form-label"], "label" => "Mot de passe"]);
yield "
";
// line 64
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["registrationForm"] ?? null), "plainPassword", [], "any", false, false, false, 64), 'widget', ["attr" => ["class" => "form-control", "placeholder" => "Votre mot de passe", "onfocus" => "this.placeholder = ''", "onblur" => "this.placeholder = 'Votre mot de passe'", "id" => "registration_password"]]);
yield "
";
// line 65
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["registrationForm"] ?? null), "plainPassword", [], "any", false, false, false, 65), 'errors');
yield "
<small class=\"form-text text-muted password-validation-message\"></small>
<div class=\"password-strength mt-2\" style=\"display: none;\">
<div class=\"progress\" style=\"height: 5px;\">
<div class=\"progress-bar\" role=\"progressbar\" style=\"width: 0%\"></div>
</div>
<small class=\"strength-text\"></small>
</div>
</div>
<div class=\"col-md-12 form-group\">
<div class=\"creat_account\">
";
// line 76
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["registrationForm"] ?? null), "agreeTerms", [], "any", false, false, false, 76), 'widget');
yield "
";
// line 77
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["registrationForm"] ?? null), "agreeTerms", [], "any", false, false, false, 77), 'label', ["label" => "Accepte les conditions"]);
yield "
";
// line 78
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["registrationForm"] ?? null), "agreeTerms", [], "any", false, false, false, 78), 'errors');
yield "
</div>
</div>
<div class=\"col-md-12 form-group\">
<button class=\"primary-btn\" type=\"submit\">
S'inscrire
</button>
<a href=\"";
// line 86
yield $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("ui_app_login");
yield "\">Déjà un compte? <b>Se connecter</b></a>
</div>
";
// line 89
yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->renderBlock(($context["registrationForm"] ?? null), 'form_end');
yield "
</div>
</div>
</div>
</div>
</section>
";
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
$__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
yield from [];
}
// line 97
/**
* @return iterable<null|scalar|\Stringable>
*/
public function block_javascripts(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
$__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "javascripts"));
$__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "javascripts"));
// line 98
yield "<script>
document.addEventListener('DOMContentLoaded', function() {
const emailInput = document.getElementById('registration_email');
const passwordInput = document.getElementById('registration_password');
const emailMessage = document.querySelector('.email-validation-message');
const passwordMessage = document.querySelector('.password-validation-message');
const passwordStrength = document.querySelector('.password-strength');
const progressBar = passwordStrength.querySelector('.progress-bar');
const strengthText = passwordStrength.querySelector('.strength-text');
const registrationForm = document.querySelector('.needs-validation');
// Validation email en temps réel
if (emailInput) {
emailInput.addEventListener('blur', function() {
validateEmail(this.value);
});
emailInput.addEventListener('input', function() {
if (this.value.length > 0) {
validateEmail(this.value);
} else {
emailMessage.textContent = '';
emailMessage.className = 'form-text text-muted email-validation-message';
}
});
}
// Validation mot de passe en temps réel
if (passwordInput) {
passwordInput.addEventListener('input', function() {
validatePassword(this.value);
});
passwordInput.addEventListener('blur', function() {
if (this.value.length > 0) {
validatePassword(this.value);
}
});
}
function validateEmail(email) {
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\$/;
if (!email) {
emailMessage.textContent = '';
emailMessage.className = 'form-text text-muted email-validation-message';
return false;
}
if (!emailRegex.test(email)) {
emailMessage.textContent = 'Format d\\'email invalide. Exemple: exemple@domaine.com';
emailMessage.className = 'form-text text-danger email-validation-message';
emailInput.classList.add('is-invalid');
emailInput.classList.remove('is-valid');
return false;
}
// Vérifier les domaines invalides communs
const invalidDomains = ['test.com', 'example.com', 'invalid.com'];
const domain = email.split('@')[1];
if (invalidDomains.includes(domain)) {
emailMessage.textContent = 'Veuillez utiliser une adresse email valide.';
emailMessage.className = 'form-text text-danger email-validation-message';
emailInput.classList.add('is-invalid');
emailInput.classList.remove('is-valid');
return false;
}
emailMessage.textContent = '✓ Adresse email valide';
emailMessage.className = 'form-text text-success email-validation-message';
emailInput.classList.remove('is-invalid');
emailInput.classList.add('is-valid');
return true;
}
function validatePassword(password) {
const minLength = 8;
const hasUpperCase = /[A-Z]/.test(password);
const hasLowerCase = /[a-z]/.test(password);
const hasNumber = /\\d/.test(password);
const hasSpecialChar = /[!@#\$%^&*(),.?\":{}|<>]/.test(password);
if (!password) {
passwordMessage.textContent = '';
passwordMessage.className = 'form-text text-muted password-validation-message';
passwordStrength.style.display = 'none';
return false;
}
let messages = [];
let strength = 0;
if (password.length >= minLength) {
strength += 25;
} else {
messages.push(`Au moins \${minLength} caractères`);
}
if (hasUpperCase) {
strength += 25;
} else {
messages.push('Une majuscule');
}
if (hasLowerCase) {
strength += 25;
} else {
messages.push('Une minuscule');
}
if (hasNumber) {
strength += 25;
} else {
messages.push('Un chiffre');
}
// Bonus pour caractère spécial
if (hasSpecialChar) {
strength = Math.min(100, strength + 10);
}
// Mettre à jour la barre de progression
progressBar.style.width = strength + '%';
if (strength < 50) {
progressBar.className = 'progress-bar bg-danger';
strengthText.textContent = 'Faible';
strengthText.className = 'strength-text text-danger';
} else if (strength < 75) {
progressBar.className = 'progress-bar bg-warning';
strengthText.textContent = 'Moyen';
strengthText.className = 'strength-text text-warning';
} else {
progressBar.className = 'progress-bar bg-success';
strengthText.textContent = 'Fort';
strengthText.className = 'strength-text text-success';
}
passwordStrength.style.display = 'block';
if (messages.length > 0) {
passwordMessage.textContent = 'Le mot de passe doit contenir: ' + messages.join(', ');
passwordMessage.className = 'form-text text-danger password-validation-message';
passwordInput.classList.add('is-invalid');
passwordInput.classList.remove('is-valid');
return false;
} else {
passwordMessage.textContent = '✓ Mot de passe valide';
passwordMessage.className = 'form-text text-success password-validation-message';
passwordInput.classList.remove('is-invalid');
passwordInput.classList.add('is-valid');
return true;
}
}
// Validation avant soumission
if (registrationForm) {
registrationForm.addEventListener('submit', function(e) {
const emailValid = validateEmail(emailInput.value);
const passwordValid = validatePassword(passwordInput.value);
if (!emailValid || !passwordValid) {
e.preventDefault();
e.stopPropagation();
if (!emailValid) {
emailInput.focus();
} else if (!passwordValid) {
passwordInput.focus();
}
}
registrationForm.classList.add('was-validated');
});
}
});
</script>
";
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
$__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
yield from [];
}
/**
* @codeCoverageIgnore
*/
public function getTemplateName(): string
{
return "registration/register.html.twig";
}
/**
* @codeCoverageIgnore
*/
public function isTraitable(): bool
{
return false;
}
/**
* @codeCoverageIgnore
*/
public function getDebugInfo(): array
{
return array ( 285 => 98, 272 => 97, 254 => 89, 248 => 86, 237 => 78, 233 => 77, 229 => 76, 215 => 65, 211 => 64, 207 => 63, 200 => 59, 196 => 58, 192 => 57, 188 => 55, 182 => 52, 178 => 51, 175 => 50, 173 => 49, 169 => 48, 158 => 40, 151 => 36, 139 => 27, 136 => 26, 127 => 24, 123 => 23, 111 => 14, 101 => 6, 88 => 5, 65 => 3, 42 => 1,);
}
public function getSourceContext(): Source
{
return new Source("{% extends 'base_home.html.twig' %}
{% block title %}Inscription | MaketOu{% endblock %}
{% block body %}
<!-- Start Banner Area -->
<section class=\"banner-area organic-breadcrumb\">
<div class=\"container\">
<div class=\"breadcrumb-banner d-flex flex-wrap align-items-center justify-content-end\">
<div class=\"col-first\">
<h1>Inscription</h1>
<nav class=\"d-flex align-items-center\">
<a href=\"{{ path('ui_home') }}\">Accueil<span class=\"lnr lnr-arrow-right\"></span></a>
<a href=\"javascript:void(0)\">Inscription</a>
</nav>
</div>
</div>
</div>
</section>
<!-- End Banner Area -->
{% for flash_error in app.flashes('verify_email_error') %}
<div class=\"alert alert-danger\" role=\"alert\">{{ flash_error }}</div>
{% endfor %}
{{ form_errors(registrationForm) }}
<!--================Login Box Area =================-->
<section class=\"login_box_area section_gap\">
<div class=\"container\">
<div class=\"row\">
<div class=\"col-lg-6\">
<div class=\"login_box_img\">
<img class=\"img-fluid\" src=\"{{ asset('ui/img/login.jpg') }}\" alt=\"\">
<div class=\"hover\">
<h4>Vous avez un compte?</h4>
<p>Connectez-vous à votre compte pour accéder à vos commandes, suivre vos livraisons et gérer vos préférences personnelles.</p>
<a class=\"primary-btn\" href=\"{{ path('ui_app_login') }}\">Se connecter</a>
</div>
</div>
</div>
<div class=\"col-lg-6\">
<div class=\"login_form_inner\">
<h3>S'inscrire</h3>
{{ form_start(registrationForm, {'attr': {'class': 'needs-validation row login_form'}}) }}
{% if app.user %}
<div class=\"mb-3\">
Vous êtes connecté comme {{ app.user.userIdentifier }}, <a
href=\"{{ path('ui_app_logout') }}\">Déconnexion</a>
</div>
{% endif %}
<div class=\"col-md-12 form-group\">
{{ form_label(registrationForm.email, 'Email', {'label_attr': {'class': 'form-label'}}) }}
{{ form_widget(registrationForm.email, {'attr': {'class': 'form-control', 'placeholder': 'email@example.com', 'onfocus':\"this.placeholder = ''\", 'onblur':\"this.placeholder = 'email@example.com'\", 'id': 'registration_email'}}) }}
{{ form_errors(registrationForm.email) }}
<small class=\"form-text text-muted email-validation-message\"></small>
</div>
<div class=\"col-md-12 form-group\">
{{ form_label(registrationForm.plainPassword, 'Mot de passe', {'label_attr': {'class': 'form-label'}}) }}
{{ form_widget(registrationForm.plainPassword, {'attr': {'class': 'form-control', 'placeholder': 'Votre mot de passe', 'onfocus':\"this.placeholder = ''\", 'onblur':\"this.placeholder = 'Votre mot de passe'\", 'id': 'registration_password'}}) }}
{{ form_errors(registrationForm.plainPassword) }}
<small class=\"form-text text-muted password-validation-message\"></small>
<div class=\"password-strength mt-2\" style=\"display: none;\">
<div class=\"progress\" style=\"height: 5px;\">
<div class=\"progress-bar\" role=\"progressbar\" style=\"width: 0%\"></div>
</div>
<small class=\"strength-text\"></small>
</div>
</div>
<div class=\"col-md-12 form-group\">
<div class=\"creat_account\">
{{ form_widget(registrationForm.agreeTerms) }}
{{ form_label(registrationForm.agreeTerms, 'Accepte les conditions') }}
{{ form_errors(registrationForm.agreeTerms) }}
</div>
</div>
<div class=\"col-md-12 form-group\">
<button class=\"primary-btn\" type=\"submit\">
S'inscrire
</button>
<a href=\"{{ path('ui_app_login') }}\">Déjà un compte? <b>Se connecter</b></a>
</div>
{{ form_end(registrationForm) }}
</div>
</div>
</div>
</div>
</section>
{% endblock %}
{% block javascripts %}
<script>
document.addEventListener('DOMContentLoaded', function() {
const emailInput = document.getElementById('registration_email');
const passwordInput = document.getElementById('registration_password');
const emailMessage = document.querySelector('.email-validation-message');
const passwordMessage = document.querySelector('.password-validation-message');
const passwordStrength = document.querySelector('.password-strength');
const progressBar = passwordStrength.querySelector('.progress-bar');
const strengthText = passwordStrength.querySelector('.strength-text');
const registrationForm = document.querySelector('.needs-validation');
// Validation email en temps réel
if (emailInput) {
emailInput.addEventListener('blur', function() {
validateEmail(this.value);
});
emailInput.addEventListener('input', function() {
if (this.value.length > 0) {
validateEmail(this.value);
} else {
emailMessage.textContent = '';
emailMessage.className = 'form-text text-muted email-validation-message';
}
});
}
// Validation mot de passe en temps réel
if (passwordInput) {
passwordInput.addEventListener('input', function() {
validatePassword(this.value);
});
passwordInput.addEventListener('blur', function() {
if (this.value.length > 0) {
validatePassword(this.value);
}
});
}
function validateEmail(email) {
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\$/;
if (!email) {
emailMessage.textContent = '';
emailMessage.className = 'form-text text-muted email-validation-message';
return false;
}
if (!emailRegex.test(email)) {
emailMessage.textContent = 'Format d\\'email invalide. Exemple: exemple@domaine.com';
emailMessage.className = 'form-text text-danger email-validation-message';
emailInput.classList.add('is-invalid');
emailInput.classList.remove('is-valid');
return false;
}
// Vérifier les domaines invalides communs
const invalidDomains = ['test.com', 'example.com', 'invalid.com'];
const domain = email.split('@')[1];
if (invalidDomains.includes(domain)) {
emailMessage.textContent = 'Veuillez utiliser une adresse email valide.';
emailMessage.className = 'form-text text-danger email-validation-message';
emailInput.classList.add('is-invalid');
emailInput.classList.remove('is-valid');
return false;
}
emailMessage.textContent = '✓ Adresse email valide';
emailMessage.className = 'form-text text-success email-validation-message';
emailInput.classList.remove('is-invalid');
emailInput.classList.add('is-valid');
return true;
}
function validatePassword(password) {
const minLength = 8;
const hasUpperCase = /[A-Z]/.test(password);
const hasLowerCase = /[a-z]/.test(password);
const hasNumber = /\\d/.test(password);
const hasSpecialChar = /[!@#\$%^&*(),.?\":{}|<>]/.test(password);
if (!password) {
passwordMessage.textContent = '';
passwordMessage.className = 'form-text text-muted password-validation-message';
passwordStrength.style.display = 'none';
return false;
}
let messages = [];
let strength = 0;
if (password.length >= minLength) {
strength += 25;
} else {
messages.push(`Au moins \${minLength} caractères`);
}
if (hasUpperCase) {
strength += 25;
} else {
messages.push('Une majuscule');
}
if (hasLowerCase) {
strength += 25;
} else {
messages.push('Une minuscule');
}
if (hasNumber) {
strength += 25;
} else {
messages.push('Un chiffre');
}
// Bonus pour caractère spécial
if (hasSpecialChar) {
strength = Math.min(100, strength + 10);
}
// Mettre à jour la barre de progression
progressBar.style.width = strength + '%';
if (strength < 50) {
progressBar.className = 'progress-bar bg-danger';
strengthText.textContent = 'Faible';
strengthText.className = 'strength-text text-danger';
} else if (strength < 75) {
progressBar.className = 'progress-bar bg-warning';
strengthText.textContent = 'Moyen';
strengthText.className = 'strength-text text-warning';
} else {
progressBar.className = 'progress-bar bg-success';
strengthText.textContent = 'Fort';
strengthText.className = 'strength-text text-success';
}
passwordStrength.style.display = 'block';
if (messages.length > 0) {
passwordMessage.textContent = 'Le mot de passe doit contenir: ' + messages.join(', ');
passwordMessage.className = 'form-text text-danger password-validation-message';
passwordInput.classList.add('is-invalid');
passwordInput.classList.remove('is-valid');
return false;
} else {
passwordMessage.textContent = '✓ Mot de passe valide';
passwordMessage.className = 'form-text text-success password-validation-message';
passwordInput.classList.remove('is-invalid');
passwordInput.classList.add('is-valid');
return true;
}
}
// Validation avant soumission
if (registrationForm) {
registrationForm.addEventListener('submit', function(e) {
const emailValid = validateEmail(emailInput.value);
const passwordValid = validatePassword(passwordInput.value);
if (!emailValid || !passwordValid) {
e.preventDefault();
e.stopPropagation();
if (!emailValid) {
emailInput.focus();
} else if (!passwordValid) {
passwordInput.focus();
}
}
registrationForm.classList.add('was-validated');
});
}
});
</script>
{% endblock %}
", "registration/register.html.twig", "/home/u540977899/domains/maketou-ht.com/public_html/templates/registration/register.html.twig");
}
}