fix: clean auth hashing and login message
This commit is contained in:
@@ -42,8 +42,8 @@ class UserLoginStartCommand:
|
|||||||
|
|
||||||
exists = await self._unit_of_work.user_repository.exists_by_email(email)
|
exists = await self._unit_of_work.user_repository.exists_by_email(email)
|
||||||
if not exists:
|
if not exists:
|
||||||
self._logger.info(f'Login failed: email already registered ({email})')
|
self._logger.info(f'Login failed: email not registered ({email})')
|
||||||
raise ApplicationException(404, 'Email registered')
|
raise ApplicationException(404, 'Email not registered')
|
||||||
|
|
||||||
trace_id = trace_id_var.get()
|
trace_id = trace_id_var.get()
|
||||||
if not trace_id or trace_id == 'N/A':
|
if not trace_id or trace_id == 'N/A':
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ from src.application.contracts import IHashService, ILogger
|
|||||||
class HashService(IHashService):
|
class HashService(IHashService):
|
||||||
|
|
||||||
def __init__(self, logger: ILogger):
|
def __init__(self, logger: ILogger):
|
||||||
self._logger = logger
|
pass
|
||||||
|
|
||||||
async def hash(self, value: str) -> str:
|
async def hash(self, value: str) -> str:
|
||||||
hashed_value = bcrypt.hashpw(value.encode(), bcrypt.gensalt())
|
hashed_value = bcrypt.hashpw(value.encode(), bcrypt.gensalt())
|
||||||
self._logger.info(f'Hash value {hashed_value.decode()}')
|
|
||||||
return hashed_value.decode()
|
return hashed_value.decode()
|
||||||
|
|
||||||
async def verify(self, hashed_value: str, plain_value: str) -> bool:
|
async def verify(self, hashed_value: str, plain_value: str) -> bool:
|
||||||
self._logger.info(f'Hash value {hashed_value[:10]}')
|
|
||||||
return bcrypt.checkpw(plain_value.encode(), hashed_value.encode())
|
return bcrypt.checkpw(plain_value.encode(), hashed_value.encode())
|
||||||
Reference in New Issue
Block a user