-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get signup working and login working cleanly.
- Loading branch information
Showing
7 changed files
with
150 additions
and
13 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Signup</title> | ||
</head> | ||
<body> | ||
<h1>Sign Up</h1> | ||
<!-- Display flash messages --> | ||
{% with messages = get_flashed_messages(with_categories=true) %} | ||
{% if messages %} | ||
<ul> | ||
{% for category, message in messages %} | ||
<li style="color: {% if category == 'error' %}red{% else %}green{% endif %};">{{ message }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
{% endwith %} | ||
<!-- Signup form --> | ||
<form action="{{ url_for('signup') }}" method="post"> | ||
<label for="username">Username:</label><br> | ||
<input type="text" name="username" id="username" required autofocus><br><br> | ||
|
||
<label for="email">Email:</label><br> | ||
<input type="text" name="email" id="email" required><br><br> | ||
|
||
<label for="password">Password:</label><br> | ||
<input type="password" name="password" id="password" required><br><br> | ||
|
||
<label for="confirm_password">Confirm Password:</label><br> | ||
<input type="password" name="confirm_password" id="confirm_password" required><br><br> | ||
|
||
<button type="submit">Register</button> | ||
</form> | ||
<p>Already have an account? <a href="{{ url_for('login') }}">Log in here</a>.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
from bson.objectid import ObjectId | ||
from werkzeug.security import generate_password_hash, check_password_hash | ||
|
||
from vonlib import database_driver as vondb | ||
|
||
config = {} | ||
|
@@ -42,13 +44,36 @@ def set_userDB(cls, userdb_name=vonuserdb, usercollection_name=vonusercollection | |
if user_collection is None: | ||
raise Exception(f"Collection {usercollection_name} does not exist and could not be created.") | ||
|
||
# put self in 湛 Zhan von Neumarkt <[email protected]> | ||
user_collection.insert_one({'username': 'zhan', 'email': '[email protected]','password': 'password'}) | ||
|
||
cls.userdb = user_database | ||
cls.usercollection = user_collection | ||
print(f"VonUser: DB={cls.userdb.name}, Coll={cls.usercollection.name}") | ||
|
||
@classmethod | ||
def create_user(cls, username, email, password): | ||
""" | ||
Creates a new user in the user database collection. | ||
This method creates a new user document in the user database collection. The user document | ||
contains the provided username, email, and password. | ||
Args: | ||
username (str): The username of the new user. | ||
email (str): The email of the new user. | ||
password (str): The password of the new user. | ||
Returns: | ||
VonUser: A VonUser object representing the new user. | ||
""" | ||
|
||
user_dict = { | ||
'username': username, | ||
'email': email, | ||
'password': password #should be hashed by now | ||
} | ||
|
||
cls.get_userCollection().insert_one(user_dict) | ||
return VonUser(username) | ||
|
||
@classmethod | ||
def get_userCollection(cls): | ||
return cls.usercollection | ||
|
@@ -64,6 +89,12 @@ def find_by_id(cls, id): | |
return None | ||
return VonUser(vu['username']) #return VonUser object | ||
|
||
@classmethod | ||
def find_by_username(cls, username): | ||
vu=cls.get_userCollection().find_one({"username": username}) | ||
if vu is None: | ||
return None | ||
return VonUser(username) #return VonUser object | ||
|
||
|
||
def __init__(self, username): | ||
|
Binary file modified
BIN
+0 Bytes
(100%)
tests/test_vonlib/__pycache__/llmconnect_test.cpython-312-pytest-8.2.2.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters