Codingo / backend /templates /signup.html
husseinelsaadi's picture
fixed-login
d8acd61
{% extends "base.html" %}
{% block title %}Codingo - Sign Up{% endblock %}
{% block content %}
<section class="content-section">
<div class="container">
<div class="card" style="max-width: 500px; margin: 2rem auto;">
<div class="card-header">
<h2 style="text-align: center; margin: 0; color: white;">Sign Up for Codingo</h2>
</div>
<div class="card-body">
<form method="POST" class="auth-form">
{{ form.hidden_tag() }}
<div class="form-group">
{{ form.username.label(class="form-label") }}
{{ form.username(class="form-control", placeholder="Choose a username") }}
{% if form.username.errors %}
<div class="alert alert-danger">
{% for error in form.username.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% endif %}
</div>
<div class="form-group">
{{ form.email.label(class="form-label") }}
{{ form.email(class="form-control", placeholder="Enter your email") }}
{% if form.email.errors %}
<div class="alert alert-danger">
{% for error in form.email.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% endif %}
</div>
<div class="form-group">
{{ form.password.label(class="form-label") }}
{{ form.password(class="form-control", placeholder="Create a password") }}
{% if form.password.errors %}
<div class="alert alert-danger">
{% for error in form.password.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% endif %}
<div class="password-strength">
<div class="password-strength-bar" id="password-strength-bar"></div>
</div>
</div>
<div class="form-group">
{{ form.confirm_password.label(class="form-label") }}
{{ form.confirm_password(class="form-control", placeholder="Confirm your password") }}
{% if form.confirm_password.errors %}
<div class="alert alert-danger">
{% for error in form.confirm_password.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% endif %}
</div>
<div class="form-group">
{{ form.role.label(class="form-label") }}
{{ form.role(class="form-control") }}
{% if form.role.errors %}
<div class="alert alert-danger">
{% for error in form.role.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% endif %}
</div>
<div class="form-group" style="margin-top: 2rem;">
{{ form.submit(class="btn btn-primary", style="width: 100%;") }}
</div>
</form>
<div style="text-align: center; margin-top: 1.5rem;">
<p>Already have an account? <a href="{{ url_for('auth.login') }}" style="color: var(--primary); font-weight: 500;">Login here</a>.</p>
</div>
</div>
</div>
</div>
</section>
<style>
.auth-form .form-label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
color: var(--dark);
}
.auth-form .form-control {
width: 100%;
padding: 0.75rem;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 1rem;
transition: all 0.3s ease;
}
.auth-form .form-control:focus {
border-color: var(--primary);
outline: none;
box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}
.auth-form .btn-primary {
background: linear-gradient(135deg, var(--primary), var(--secondary));
color: white;
padding: 0.75rem;
border: none;
border-radius: 5px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
z-index: 1;
}
.auth-form .btn-primary::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 0%;
height: 100%;
background-color: rgba(255, 255, 255, 0.1);
transition: all 0.3s ease;
z-index: -1;
}
.auth-form .btn-primary:hover::before {
width: 100%;
}
.auth-form .btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.alert-danger {
color: var(--danger);
background-color: rgba(231, 76, 60, 0.1);
border: 1px solid var(--danger);
border-radius: 5px;
padding: 0.5rem;
margin-top: 0.5rem;
font-size: 0.9rem;
}
.password-strength {
height: 5px;
width: 100%;
background-color: #eee;
margin-top: 5px;
border-radius: 3px;
overflow: hidden;
}
.password-strength-bar {
height: 100%;
width: 0;
border-radius: 3px;
transition: width 0.3s, background-color 0.3s;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function() {
const passwordInput = document.querySelector('input[name="password"]');
const strengthBar = document.getElementById('password-strength-bar');
if (passwordInput && strengthBar) {
passwordInput.addEventListener('input', function() {
const password = this.value;
const strength = checkPasswordStrength(password);
strengthBar.style.width = `${strength.percentage}%`;
strengthBar.style.backgroundColor = strength.color;
});
}
function checkPasswordStrength(password) {
const requirements = {
length: password.length >= 8,
uppercase: /[A-Z]/.test(password),
lowercase: /[a-z]/.test(password),
number: /\d/.test(password),
special: /[^A-Za-z0-9]/.test(password)
};
const strength = Object.values(requirements).filter(Boolean).length;
const percentage = (strength / 5) * 100;
return {
valid: Object.values(requirements).every(Boolean),
percentage,
color: strength < 2 ? '#e74c3c' : strength < 4 ? '#f39c12' : '#27ae60'
};
}
});
</script>
{% endblock %}