Skip to content

Commit ef5e848

Browse files
author
Davidson Gomes
committed
Merge branch 'release/0.0.9'
2 parents d0f40e7 + ae62a55 commit ef5e848

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+785
-505
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.0.8] - 2025-05-14
8+
## [0.0.9] - 2025-05-13
9+
10+
### Changed
11+
12+
- Enhance user authentication with detailed error handling
13+
14+
## [0.0.8] - 2025-05-13
915

1016
### Changed
1117

1218
- Update author information in multiple files
1319

14-
## [0.0.7] - 2025-05-14
20+
## [0.0.7] - 2025-05-13
1521

1622
### Added
1723

conftest.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
"""
2+
┌──────────────────────────────────────────────────────────────────────────────┐
3+
│ @author: Davidson Gomes │
4+
│ @file: conftest.py │
5+
│ Developed by: Davidson Gomes │
6+
│ Creation date: May 13, 2025 │
7+
│ Contact: contato@evolution-api.com │
8+
├──────────────────────────────────────────────────────────────────────────────┤
9+
│ @copyright © Evolution API 2025. All rights reserved. │
10+
│ Licensed under the Apache License, Version 2.0 │
11+
│ │
12+
│ You may not use this file except in compliance with the License. │
13+
│ You may obtain a copy of the License at │
14+
│ │
15+
│ http://www.apache.org/licenses/LICENSE-2.0 │
16+
│ │
17+
│ Unless required by applicable law or agreed to in writing, software │
18+
│ distributed under the License is distributed on an "AS IS" BASIS, │
19+
│ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. │
20+
│ See the License for the specific language governing permissions and │
21+
│ limitations under the License. │
22+
├──────────────────────────────────────────────────────────────────────────────┤
23+
│ @important │
24+
│ For any future changes to the code in this file, it is recommended to │
25+
│ include, together with the modification, the information of the developer │
26+
│ who changed it and the date of modification. │
27+
└──────────────────────────────────────────────────────────────────────────────┘
28+
"""
29+
130
import pytest
231
from fastapi.testclient import TestClient
332
from sqlalchemy import create_engine
@@ -22,23 +51,23 @@
2251
def db_session():
2352
"""Creates a fresh database session for each test."""
2453
Base.metadata.create_all(bind=engine) # Create tables
25-
54+
2655
connection = engine.connect()
2756
transaction = connection.begin()
2857
session = TestingSessionLocal(bind=connection)
29-
58+
3059
# Use our test database instead of the standard one
3160
def override_get_db():
3261
try:
3362
yield session
3463
session.commit()
3564
finally:
3665
session.close()
37-
66+
3867
app.dependency_overrides[get_db] = override_get_db
39-
68+
4069
yield session # The test will run here
41-
70+
4271
# Teardown
4372
transaction.rollback()
4473
connection.close()
@@ -50,4 +79,4 @@ def override_get_db():
5079
def client(db_session):
5180
"""Creates a FastAPI TestClient with database session fixture."""
5281
with TestClient(app) as test_client:
53-
yield test_client
82+
yield test_client

scripts/seeders/admin_seeder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
┌──────────────────────────────────────────────────────────────────────────────┐
33
│ @author: Davidson Gomes │
4-
│ @file: run_seeders.py
4+
│ @file: admin_seeder.py │
55
│ Developed by: Davidson Gomes │
66
│ Creation date: May 13, 2025 │
77
│ Contact: contato@evolution-api.com │

scripts/seeders/client_seeder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
┌──────────────────────────────────────────────────────────────────────────────┐
33
│ @author: Davidson Gomes │
4-
│ @file: run_seeders.py
4+
│ @file: client_seeder.py │
55
│ Developed by: Davidson Gomes │
66
│ Creation date: May 13, 2025 │
77
│ Contact: contato@evolution-api.com │

scripts/seeders/mcp_server_seeder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
┌──────────────────────────────────────────────────────────────────────────────┐
33
│ @author: Davidson Gomes │
4-
│ @file: run_seeders.py
4+
│ @file: mcp_server_seeder.py │
55
│ Developed by: Davidson Gomes │
66
│ Creation date: May 13, 2025 │
77
│ Contact: contato@evolution-api.com │

scripts/seeders/tool_seeder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
┌──────────────────────────────────────────────────────────────────────────────┐
33
│ @author: Davidson Gomes │
4-
│ @file: run_seeders.py │
4+
│ @file: tool_seeder.py │
55
│ Developed by: Davidson Gomes │
66
│ Creation date: May 13, 2025 │
77
│ Contact: contato@evolution-api.com │

src/api/a2a_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
┌──────────────────────────────────────────────────────────────────────────────┐
33
│ @author: Davidson Gomes │
4-
│ @file: run_seeders.py │
4+
│ @file: a2a_routes.py
55
│ Developed by: Davidson Gomes │
66
│ Creation date: May 13, 2025 │
77
│ Contact: contato@evolution-api.com │

src/api/admin_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
┌──────────────────────────────────────────────────────────────────────────────┐
33
│ @author: Davidson Gomes │
4-
│ @file: run_seeders.py
4+
│ @file: admin_routes.py │
55
│ Developed by: Davidson Gomes │
66
│ Creation date: May 13, 2025 │
77
│ Contact: contato@evolution-api.com │

src/api/agent_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
┌──────────────────────────────────────────────────────────────────────────────┐
33
│ @author: Davidson Gomes │
4-
│ @file: run_seeders.py
4+
│ @file: agent_routes.py │
55
│ Developed by: Davidson Gomes │
66
│ Creation date: May 13, 2025 │
77
│ Contact: contato@evolution-api.com │

src/api/auth_routes.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
┌──────────────────────────────────────────────────────────────────────────────┐
33
│ @author: Davidson Gomes │
4-
│ @file: run_seeders.py │
4+
│ @file: auth_routes.py │
55
│ Developed by: Davidson Gomes │
66
│ Creation date: May 13, 2025 │
77
│ Contact: contato@evolution-api.com │
@@ -191,14 +191,36 @@ async def login_for_access_token(form_data: UserLogin, db: Session = Depends(get
191191
Raises:
192192
HTTPException: If credentials are invalid
193193
"""
194-
user = authenticate_user(db, form_data.email, form_data.password)
194+
user, reason = authenticate_user(db, form_data.email, form_data.password)
195195
if not user:
196-
logger.warning(f"Login attempt with invalid credentials: {form_data.email}")
197-
raise HTTPException(
198-
status_code=status.HTTP_401_UNAUTHORIZED,
199-
detail="Invalid email or password",
200-
headers={"WWW-Authenticate": "Bearer"},
201-
)
196+
if reason == "user_not_found" or reason == "invalid_password":
197+
logger.warning(f"Login attempt with invalid credentials: {form_data.email}")
198+
raise HTTPException(
199+
status_code=status.HTTP_401_UNAUTHORIZED,
200+
detail="Invalid email or password",
201+
headers={"WWW-Authenticate": "Bearer"},
202+
)
203+
elif reason == "email_not_verified":
204+
logger.warning(f"Login attempt with unverified email: {form_data.email}")
205+
raise HTTPException(
206+
status_code=status.HTTP_403_FORBIDDEN,
207+
detail="Email not verified",
208+
)
209+
elif reason == "inactive_user":
210+
logger.warning(f"Login attempt with inactive user: {form_data.email}")
211+
raise HTTPException(
212+
status_code=status.HTTP_403_FORBIDDEN,
213+
detail="User account is inactive",
214+
)
215+
else:
216+
logger.warning(
217+
f"Login attempt failed for {form_data.email} (reason: {reason})"
218+
)
219+
raise HTTPException(
220+
status_code=status.HTTP_401_UNAUTHORIZED,
221+
detail="Invalid email or password",
222+
headers={"WWW-Authenticate": "Bearer"},
223+
)
202224

203225
access_token = create_access_token(user)
204226
logger.info(f"Login successful for user: {user.email}")

0 commit comments

Comments
 (0)