Updated to include mockup of login

This commit is contained in:
Tracker-Friendly 2023-11-19 13:48:33 +00:00
parent 96651720fd
commit 21df5e55df
10 changed files with 108 additions and 4 deletions

View File

@ -1,5 +1,13 @@
[HectaMail]
[Signup]
# Secret Key, please change to something custom
secretkey: secret_key_here
# The characters you allow in your CAPTCHA
captchachars: ABCDEFGHIJKLMNOPQRSTUVWXYZ
# The port the server should run on
port: 8050
[Login]
# The port the server should run on
port: 8040
# The location of the maddy database
dblocation: /var/lib/maddy/credentials.db

57
login/login.py Normal file
View File

@ -0,0 +1,57 @@
from flask import Flask, render_template, request
import bcrypt
import sqlite3
import configparser
from waitress import serve
# Load from config.ini
config = configparser.ConfigParser()
config.read("config.ini")
database = config.get("Login", "database")
runport = config.get("Login", "port")
# Status report
print("HectaMail Login Service is starting up...")
print("Your database is located at:", database)
app = Flask(__name__)
def fetch_hash_from_database(key):
conn = sqlite3.connect(database)
cursor = conn.cursor()
cursor.execute("SELECT value FROM passwords WHERE key = ?", (key,))
result = cursor.fetchone()
conn.close()
if result:
return result[0][7:] # Remove the first 7 characters
else:
return None
def verify_bcrypt(passphrase, hashed_password):
return bcrypt.checkpw(passphrase.encode('utf-8'), hashed_password.encode('utf-8'))
@app.route('/')
def index():
return render_template('index.html')
@app.route('/login', methods=['POST'])
def login():
key_to_fetch = request.form['email']
password_to_check = request.form['password']
go_script_hash = fetch_hash_from_database(key_to_fetch)
if go_script_hash:
is_password_valid = verify_bcrypt(password_to_check, go_script_hash)
if is_password_valid:
return "Logged in successfully"
else:
return "Incorrect email or password"
else:
return "Email not found in the database"
if __name__ == '__main__':
serve(app, host='0.0.0.0', port=runport)

View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Login</title>
<link rel="stylesheet" href="/static/css/main.css">
</head>
<body>
<div class="headerbar">
<a href="/">HectaMail</a>
<a href="/register">Sign up</a>
<a class="main" href="/login">Login</a>
</div>
<div class="content">
<h1>Login to your Email Account</h1>
<p1>Warning! This is only a proof of concept and has no actual use!</p1>
<form method="POST" action="/login">
<label for="username">Email</label>
<div class="spacer">
<input type="text" name="email" required="">
</div>
<br>
<div class="Password">
<label for="password">Password</label>
<div class="spacer">
<input type="password" name="password" required="">
</div>
</div>
<br>
<input type="submit" value="Login">
</form>
</div>
<style type="text/css"></style></body></html>

View File

@ -14,8 +14,9 @@ import configparser
config = configparser.ConfigParser()
config.read("config.ini")
secretkey = config.get("HectaMail", "secretkey")
captchachars = config.get("HectaMail", "captchachars")
secretkey = config.get("Signup", "secretkey")
captchachars = config.get("Signup", "captchachars")
runport = config.get("Signup", "port")
# Status report
@ -149,4 +150,4 @@ def register():
# Start the web server
if __name__ == '__main__':
serve(app, host='0.0.0.0', port=8050)
serve(app, host='0.0.0.0', port=runport)

View File

@ -8,6 +8,7 @@
<div class="headerbar">
<a href="/">HectaMail</a>
<a class="main" href="/register">Sign up</a>
<a href="/login">Login</a>
</div>
<div class="content">
<h1>Error!</h1>

View File

@ -8,6 +8,7 @@
<div class="headerbar">
<a href="/">HectaMail</a>
<a class="main" href="/register">Sign up</a>
<a href="/login">Login</a>
</div>
<div class="content">
<h1>Error!</h1>

View File

@ -8,6 +8,7 @@
<div class="headerbar">
<a href="/">HectaMail</a>
<a class="main" href="/register">Sign up</a>
<a href="/login">Login</a>
</div>
<div class="content">
<h1>Error!</h1>

View File

@ -8,6 +8,7 @@
<div class="headerbar">
<a href="/">HectaMail</a>
<a class="main" href="/register">Sign up</a>
<a href="/login">Login</a>
</div>
<div class="content">
<h1>Register an Email Account</h1>

View File

@ -8,6 +8,7 @@
<div class="headerbar">
<a href="/">HectaMail</a>
<a class="main" href="/register">Sign up</a>
<a href="/login">Login</a>
</div>
<div class="content">
<h1>Error!</h1>

View File

@ -8,6 +8,7 @@
<div class="headerbar">
<a href="/">HectaMail</a>
<a class="main" href="/register">Sign up</a>
<a href="/login">Login</a>
</div>
<div class="content">
<h1>Done!</h1>