Skip to content

Commit eca15f3

Browse files
committed
add: debug
1 parent 6d47d59 commit eca15f3

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

app/authentication/authentication.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from app.authenticator import authenticator
88
from app.util import login_user, logout_user
99
from app.util import get_git_branch
10+
from app.settings import DEBUG_MODE
1011

1112
from . import authentication_bp
1213

@@ -30,7 +31,12 @@ def authenticate(username, password):
3031
route: /auth/signin/<username>/<password>
3132
"""
3233
login_user(username)
33-
return jsonify({'result': authenticator.authenticate(username, password)})
34+
result = authenticator.authenticate(username, password)
35+
36+
if DEBUG_MODE:
37+
print(f"[DEBUG] authentication.py: Authentication result: {result}")
38+
39+
return jsonify({'result': result})
3440

3541
@authentication_bp.route('/registration')
3642
def registration():

app/authentication/static/signin.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
document.getElementById('button-signin').addEventListener('click', function(event) {
2-
event.preventDefault(); // Prevent form submission
3-
const username = document.querySelector('input[type="text"]').value;
4-
const password = document.querySelector('input[type="password"]').value;
5-
authenticate(username, password)
1+
document.addEventListener("DOMContentLoaded", function() {
2+
document.getElementById('button-signin').addEventListener('click', function(event) {
3+
event.preventDefault(); // Prevent form submission
4+
const username = document.querySelector('input[type="text"]').value;
5+
const password = document.querySelector('input[type="password"]').value;
6+
authenticate(username, password)
7+
});
68
});
79

810
function authenticate(username, password) {
11+
console.log("[DEBUG] signin.js: authenticate() called");
912
fetch(`/auth/signin/${username}/${password}`, {
1013
method: 'GET',
1114
headers: {

app/authenticator/authenticator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from bcrypt import checkpw, gensalt, hashpw
99

1010
from app.database.user import User
11+
from app.settings import DEBUG_MODE
1112

1213
class Authenticator:
1314
"""
@@ -43,6 +44,8 @@ def verify_password(self, password, hashed_password):
4344
Returns:
4445
bool: True if the password matches the hashed password, False otherwise.
4546
"""
47+
if DEBUG_MODE:
48+
print(f"[DEBUG] authenticator.py: Verifying password: {checkpw(password.encode(), hashed_password.encode())}")
4649
return checkpw(password.encode(), hashed_password.encode())
4750

4851
def authenticate(self, username, password):

app/home/static/home-private.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
document.getElementById('button-signout').addEventListener('click', function(event) {
1+
document.addEventListener("DOMContentLoaded", function() {
2+
document.getElementById('button-signout').addEventListener('click', function(event) {
23
event.preventDefault();
34
redirect_signout();
5+
});
46
});
57

68
function redirect_signout(){

0 commit comments

Comments
 (0)