square-administration 2.4.0__py3-none-any.whl → 3.0.1__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.
@@ -10,3 +10,7 @@ class RegisterUsernameV0(BaseModel):
10
10
  class LoginUsernameV0(BaseModel):
11
11
  username: str
12
12
  password: str
13
+
14
+
15
+ class RemoveAppForSelfV0(BaseModel):
16
+ password: str
@@ -9,6 +9,10 @@ from requests import HTTPError
9
9
  from square_authentication_helper import TokenType
10
10
  from square_commons import get_api_output_in_standard_format
11
11
  from square_commons.api_utils import create_cookie
12
+ from square_database_helper.pydantic_models import FilterConditionsV0, FiltersV0
13
+ from square_database_structure.square import global_string_database_name
14
+ from square_database_structure.square.authentication import global_string_schema_name
15
+ from square_database_structure.square.authentication.tables import User, UserCredential
12
16
 
13
17
  from square_administration.configuration import (
14
18
  global_object_square_logger,
@@ -16,11 +20,13 @@ from square_administration.configuration import (
16
20
  global_object_square_authentication_helper,
17
21
  global_int_app_id,
18
22
  config_str_cookie_domain,
23
+ global_object_square_database_helper,
19
24
  )
20
25
  from square_administration.messages import messages
21
26
  from square_administration.pydantic_models.authentication import (
22
27
  RegisterUsernameV0,
23
28
  LoginUsernameV0,
29
+ RemoveAppForSelfV0,
24
30
  )
25
31
  from square_administration.utils.common import is_https
26
32
 
@@ -218,13 +224,46 @@ async def login_username_v0(
218
224
  @global_object_square_logger.async_auto_logger
219
225
  async def remove_app_for_self_v0(
220
226
  access_token: Annotated[str, Header()],
227
+ body: RemoveAppForSelfV0,
221
228
  ):
222
-
229
+ password = body.password
223
230
  try:
224
231
  """
225
232
  validation
226
233
  """
227
- # pass
234
+ access_token_payload = global_object_square_authentication_helper.validate_and_get_payload_from_token_v0(
235
+ access_token, TokenType.access_token
236
+ )
237
+ user_id = access_token_payload["data"]["main"]["user_id"]
238
+ user_credentials_response = global_object_square_database_helper.get_rows_v0(
239
+ database_name=global_string_database_name,
240
+ schema_name=global_string_schema_name,
241
+ table_name=UserCredential.__tablename__,
242
+ filters=FiltersV0(
243
+ root={
244
+ User.user_id.name: FilterConditionsV0(eq=user_id),
245
+ }
246
+ ),
247
+ columns=[UserCredential.user_credential_hashed_password.name],
248
+ )
249
+ hashed_password = user_credentials_response["data"]["main"][0][
250
+ UserCredential.user_credential_hashed_password.name
251
+ ]
252
+
253
+ if not (
254
+ bcrypt.checkpw(
255
+ password.encode("utf-8"),
256
+ hashed_password.encode("utf-8"),
257
+ )
258
+ ):
259
+ output_content = get_api_output_in_standard_format(
260
+ message=messages["INCORRECT_PASSWORD"],
261
+ log=f"incorrect password for user_id {user_id}.",
262
+ )
263
+ return JSONResponse(
264
+ status_code=status.HTTP_400_BAD_REQUEST,
265
+ content=output_content,
266
+ )
228
267
  """
229
268
  main process
230
269
  """
@@ -3,9 +3,11 @@ import os
3
3
  from square_administration.configuration import (
4
4
  config_str_ssl_key_file_path,
5
5
  config_str_ssl_crt_file_path,
6
+ global_object_square_logger,
6
7
  )
7
8
 
8
9
 
10
+ @global_object_square_logger.auto_logger
9
11
  def is_https() -> bool:
10
12
  return os.path.exists(config_str_ssl_key_file_path) and os.path.exists(
11
13
  config_str_ssl_crt_file_path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: square-administration
3
- Version: 2.4.0
3
+ Version: 3.0.1
4
4
  Summary: common business layer for my personal server.
5
5
  Home-page: https://github.com/thepmsquare/square_administration
6
6
  Author: thePmSquare
@@ -42,6 +42,14 @@ pip install square_administration
42
42
 
43
43
  ## changelog
44
44
 
45
+ ### v3.0.1
46
+
47
+ - add logging decorator to all functions.
48
+
49
+ ### v3.0.0
50
+
51
+ - add new parameter -> password in authentication -> remove_app_for_self_v0.
52
+
45
53
  ### v2.4.0
46
54
 
47
55
  - auto docker image build github action.
@@ -4,14 +4,14 @@ square_administration/main.py,sha256=YHala3fQjbj4wQuIzCWEZ3xeeVsidPLHabCUsADr4tE
4
4
  square_administration/messages.py,sha256=VYjJGW0Kvtjrx1Mw7ekksLVMoxcexLol2OckvqhZ3n0,1063
5
5
  square_administration/data/config.ini,sha256=sTWBnaNGXqLi0Ckk2cNzBC7pqrlboyU_ClLl04luOZY,1024
6
6
  square_administration/pydantic_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- square_administration/pydantic_models/authentication.py,sha256=DWXctw5UWzkSVY7nMIQZsRhmgW3OK455OVcoUpJrPY0,202
7
+ square_administration/pydantic_models/authentication.py,sha256=QEfM5ezG45hc_qATXpFIPNPl4bjf8ICW_bY5tY4cqO4,259
8
8
  square_administration/pydantic_models/core.py,sha256=HUMrBmfKrXeL-126gE5j2povdVmktn8XLg2tHEdeXTk,344
9
9
  square_administration/routes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- square_administration/routes/authentication.py,sha256=wq1JFXVfbVEy3_HGdFVk2823YgMs8qhWl_gR6Cqv_ik,14237
10
+ square_administration/routes/authentication.py,sha256=vOkuAmnPkTl-PSDmSkyui2tvhFxvo0WzMAAuz3st-QY,16053
11
11
  square_administration/routes/core.py,sha256=65_FIZilintZvbHx7r25UQbgN-oKdQ92-Nv3kpwKX6s,5374
12
12
  square_administration/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- square_administration/utils/common.py,sha256=amCGhwizka1MgM-Xlw_8f07V54Br7pOvCDtevJfz98M,276
14
- square_administration-2.4.0.dist-info/METADATA,sha256=0OVqlu4REaqVXof-Qqzkx82xrjFrI-mRW9H9QKgmbok,2078
15
- square_administration-2.4.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
16
- square_administration-2.4.0.dist-info/top_level.txt,sha256=8WFipDrMQUPRDo5AvipxU1YK3wZtWZyCUMWaR416zAw,22
17
- square_administration-2.4.0.dist-info/RECORD,,
13
+ square_administration/utils/common.py,sha256=Uk2clDugVI8U6-bgjs77fxC4DuqmJEJ_IznBs1jAtWc,350
14
+ square_administration-3.0.1.dist-info/METADATA,sha256=aviG8xNbrRwAs9SfhngddFLisn1_7RY3jsFgmYH2dec,2223
15
+ square_administration-3.0.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
16
+ square_administration-3.0.1.dist-info/top_level.txt,sha256=8WFipDrMQUPRDo5AvipxU1YK3wZtWZyCUMWaR416zAw,22
17
+ square_administration-3.0.1.dist-info/RECORD,,