square-authentication 10.0.1__py3-none-any.whl → 10.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- import bcrypt
2
1
  from fastapi import APIRouter, status, HTTPException
3
2
  from fastapi.responses import JSONResponse
4
3
  from square_commons import get_api_output_in_standard_format
5
4
 
6
5
  from square_authentication.configuration import global_object_square_logger
7
6
  from square_authentication.messages import messages
7
+ from square_authentication.utils.routes.utility import util_get_text_hash_v0
8
8
 
9
9
  router = APIRouter(
10
10
  tags=["utility"],
@@ -14,47 +14,17 @@ router = APIRouter(
14
14
  @router.get("/get_text_hash/v0")
15
15
  @global_object_square_logger.auto_logger()
16
16
  async def get_text_hash_v0(plain_text: str):
17
-
18
17
  try:
19
- """
20
- validation
21
- """
22
- # pass
23
- """
24
- main process
25
- """
26
- local_str_hashed_text = bcrypt.hashpw(
27
- plain_text.encode("utf-8"), bcrypt.gensalt()
28
- ).decode("utf-8")
29
- """
30
- return value
31
- """
32
- output_content = get_api_output_in_standard_format(
33
- message=messages["GENERIC_READ_SUCCESSFUL"],
34
- data={"main": local_str_hashed_text},
35
- )
36
- return JSONResponse(
37
- status_code=status.HTTP_200_OK,
38
- content=output_content,
39
- )
40
- except HTTPException as http_exception:
41
- global_object_square_logger.logger.error(http_exception, exc_info=True)
42
- """
43
- rollback logic
44
- """
45
- # pass
46
- return JSONResponse(
47
- status_code=http_exception.status_code, content=http_exception.detail
18
+ return util_get_text_hash_v0(
19
+ plain_text=plain_text,
48
20
  )
21
+ except HTTPException as he:
22
+ global_object_square_logger.logger.error(he, exc_info=True)
23
+ return JSONResponse(status_code=he.status_code, content=he.detail)
49
24
  except Exception as e:
50
25
  global_object_square_logger.logger.error(e, exc_info=True)
51
- """
52
- rollback logic
53
- """
54
- # pass
55
26
  output_content = get_api_output_in_standard_format(
56
- message=messages["GENERIC_500"],
57
- log=str(e),
27
+ message=messages["GENERIC_500"], log=str(e)
58
28
  )
59
29
  return JSONResponse(
60
30
  status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
File without changes