Registering works fine now
This commit is contained in:
@@ -14,14 +14,14 @@ def home():
|
||||
|
||||
@app.route('/register', methods=['GET', 'POST'])
|
||||
def register():
|
||||
import sqlLite.get as getter
|
||||
import standard.getter as st_getter
|
||||
import sqlLite.set as setter
|
||||
import useful.hash as hasher
|
||||
|
||||
if request.method == 'POST':
|
||||
username = request.form['username'].strip()
|
||||
email = request.form.get('email').strip()
|
||||
password = request.form.get('password').strip()
|
||||
pwd_confirm = request.form.get('confirm_password').strip()
|
||||
username = request.form['username']
|
||||
email = request.form.get('email')
|
||||
password = request.form.get('password')
|
||||
pwd_confirm = request.form.get('confirm_password')
|
||||
|
||||
if not email or not password or not pwd_confirm or not username:
|
||||
flash('Please fill out all fields', 'error')
|
||||
@@ -30,18 +30,22 @@ def register():
|
||||
if password != pwd_confirm:
|
||||
flash('Passwords do not match', 'error')
|
||||
return redirect(url_for('register'))
|
||||
# Hash the password
|
||||
hashed_password = hasher.sha512(password.encode('utf-8')).hexdigest()
|
||||
|
||||
try:
|
||||
# Call your setter function to add user to DB
|
||||
setter.set_login(username, email, hashed_password)
|
||||
flash('Registration successful! Please log in.', 'success')
|
||||
return redirect(url_for('login'))
|
||||
if st_getter.get_validate_email(email):
|
||||
setter.set_login(username, email, password)
|
||||
flash('Registration successful! Please log in.', 'success')
|
||||
return redirect(url_for('login'))
|
||||
else:
|
||||
flash('Invalid email format', 'error')
|
||||
return redirect(url_for('register'))
|
||||
except Exception as e:
|
||||
flash(f'Error: {str(e)}', 'error')
|
||||
return redirect(url_for('register'))
|
||||
|
||||
# For GET-requests:
|
||||
return render_template('register.html')
|
||||
|
||||
|
||||
@app.route('/login', methods=['GET', 'POST'])
|
||||
def login():
|
||||
if request.method == 'POST':
|
||||
@@ -49,6 +53,7 @@ def login():
|
||||
enter_password = request.form.get('password')
|
||||
import hashlib
|
||||
import sqlLite.get as getter
|
||||
import standard.getter as st_getter
|
||||
|
||||
stored_hash = getter.get_password_by_email(enter_email) # use email here
|
||||
|
||||
@@ -56,7 +61,7 @@ def login():
|
||||
flash("User not found!")
|
||||
return redirect(url_for("login"))
|
||||
|
||||
hash_entered = hashlib.sha512(enter_password.encode('utf-8')).hexdigest()
|
||||
hash_entered = st_getter.get_password_hash(enter_password)
|
||||
|
||||
if hash_entered == stored_hash:
|
||||
return redirect(url_for('dashboard'))
|
||||
@@ -70,4 +75,5 @@ def login():
|
||||
|
||||
@app.route('/dashboard')
|
||||
def dashboard():
|
||||
return "Welcome to the dashboard! Login successful."
|
||||
#return "Welcome to the dashboard! Login successful."
|
||||
return render_template('dashboard.html')
|
||||
|
||||
119
frontend/templates/dashboard.html
Normal file
119
frontend/templates/dashboard.html
Normal file
@@ -0,0 +1,119 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Register</title>
|
||||
<style>
|
||||
/* Use the same styling as login.html for consistency */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;600&display=swap');
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100vh;
|
||||
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
background: white;
|
||||
max-width: 400px;
|
||||
width: 100%;
|
||||
padding: 40px 30px 50px;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.2);
|
||||
text-align: center;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.login-container:hover {
|
||||
transform: translateY(-8px);
|
||||
box-shadow: 0 30px 60px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 30px;
|
||||
font-size: 28px;
|
||||
letter-spacing: 1.2px;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 25px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: #555;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
input[type="username"],
|
||||
input[type="email"],
|
||||
input[type="password"] {
|
||||
width: 100%;
|
||||
padding: 14px 18px;
|
||||
font-size: 16px;
|
||||
border-radius: 12px;
|
||||
border: 2px solid #ddd;
|
||||
transition: 0.3s border-color ease;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
input[type="email"]:focus,
|
||||
input[type="password"]:focus {
|
||||
border-color: #2575fc;
|
||||
outline: none;
|
||||
box-shadow: 0 0 12px rgba(37, 117, 252, 0.5);
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 16px 0;
|
||||
margin-top: 10px;
|
||||
background-color: #2575fc;
|
||||
border: none;
|
||||
border-radius: 14px;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 1px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 10px 20px rgba(37, 117, 252, 0.4);
|
||||
transition: background-color 0.3s ease, box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #1859d6;
|
||||
box-shadow: 0 15px 25px rgba(24, 89, 214, 0.6);
|
||||
}
|
||||
|
||||
.error-message {
|
||||
margin-top: 20px;
|
||||
color: #ff4d4f;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
text-align: center;
|
||||
background: #ffe6e6;
|
||||
padding: 10px 15px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 6px rgba(255,77,79,0.3);
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -72,6 +72,7 @@
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
input[type="username"]:focus,
|
||||
input[type="email"]:focus,
|
||||
input[type="password"]:focus {
|
||||
border-color: #2575fc;
|
||||
|
||||
Reference in New Issue
Block a user