diff options
author | Frederick Muriuki Muriithi | 2022-11-08 09:48:03 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-11-08 09:48:03 +0300 |
commit | 74c431ca4f6e015fd53f2e270e3cc89546caca56 (patch) | |
tree | 0172f58908ee1a3304c1c6c4ea84bb240f9212e6 /gn3/auth | |
parent | 8e1f297c5f788ed7b15cddd2eb62ba982c5346da (diff) | |
download | genenetwork3-74c431ca4f6e015fd53f2e270e3cc89546caca56.tar.gz |
Tests: Tests the credentials check system
* gn3/auth/authentication.py: Fix issues caught by tests
* tests/unit/auth/test_credentials.py: Add fixtures and tests for credentials
checking
Diffstat (limited to 'gn3/auth')
-rw-r--r-- | gn3/auth/authentication.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gn3/auth/authentication.py b/gn3/auth/authentication.py index 781380e..42ceacb 100644 --- a/gn3/auth/authentication.py +++ b/gn3/auth/authentication.py @@ -11,11 +11,14 @@ def credentials_in_database(cursor, email: str, password: str) -> bool: ("SELECT " "users.email, user_credentials.password " "FROM users LEFT JOIN user_credentials " - "ON users.email = :email"), + "ON users.user_id = user_credentials.user_id " + "WHERE users.email = :email"), {"email": email}) results = cursor.fetchall() if len(results) == 0: return False - assert len(results) > 1, "Expected one row." - return (email == row[0] and bcrypt.checkpw(value.encode("utf-8"), row[1])) + assert len(results) == 1, "Expected one row." + row = results[0] + return (email == row[0] and + bcrypt.checkpw(password.encode("utf-8"), row[1])) |