square-authentication 5.1.1__py3-none-any.whl → 5.1.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.
@@ -17,6 +17,7 @@ from square_database_structure.square.authentication.tables import (
17
17
  UserApp,
18
18
  UserCredential,
19
19
  UserSession,
20
+ UserProfile,
20
21
  )
21
22
  from square_database_structure.square.public import (
22
23
  global_string_schema_name as global_string_public_schema_name,
@@ -75,22 +76,20 @@ async def register_username_v0(
75
76
  """
76
77
 
77
78
  # validation for username
78
- local_list_response_user_creds = global_object_square_database_helper.get_rows_v0(
79
- database_name=global_string_database_name,
80
- schema_name=global_string_schema_name,
81
- table_name=UserCredential.__tablename__,
82
- filters=FiltersV0(
83
- root={
84
- UserCredential.user_credential_username.name: FilterConditionsV0(
85
- eq=username
86
- )
87
- }
88
- ),
89
- )[
90
- "data"
91
- ][
92
- "main"
93
- ]
79
+ local_list_response_user_creds = (
80
+ global_object_square_database_helper.get_rows_v0(
81
+ database_name=global_string_database_name,
82
+ schema_name=global_string_schema_name,
83
+ table_name=UserProfile.__tablename__,
84
+ filters=FiltersV0(
85
+ root={
86
+ UserProfile.user_profile_username.name: FilterConditionsV0(
87
+ eq=username
88
+ )
89
+ }
90
+ ),
91
+ )["data"]["main"]
92
+ )
94
93
  if len(local_list_response_user_creds) > 0:
95
94
  output_content = get_api_output_in_standard_format(
96
95
  message=messages["USERNAME_ALREADY_EXISTS"],
@@ -124,7 +123,6 @@ async def register_username_v0(
124
123
  data=[
125
124
  {
126
125
  UserCredential.user_id.name: local_str_user_id,
127
- UserCredential.user_credential_username.name: username,
128
126
  UserCredential.user_credential_hashed_password.name: local_str_hashed_password,
129
127
  }
130
128
  ],
@@ -132,6 +130,17 @@ async def register_username_v0(
132
130
  schema_name=global_string_schema_name,
133
131
  table_name=UserCredential.__tablename__,
134
132
  )
133
+ global_object_square_database_helper.insert_rows_v0(
134
+ data=[
135
+ {
136
+ UserProfile.user_id.name: local_str_user_id,
137
+ UserProfile.user_profile_username.name: username,
138
+ }
139
+ ],
140
+ database_name=global_string_database_name,
141
+ schema_name=global_string_schema_name,
142
+ table_name=UserProfile.__tablename__,
143
+ )
135
144
  if app_id is not None:
136
145
  # assign app to user
137
146
  global_object_square_database_helper.insert_rows_v0(
@@ -278,13 +287,13 @@ async def get_user_details_v0(
278
287
  root={UserApp.user_id.name: FilterConditionsV0(eq=user_id)}
279
288
  ),
280
289
  )["data"]["main"]
281
- local_list_response_user_credentials = (
290
+ local_list_response_user_profile = (
282
291
  global_object_square_database_helper.get_rows_v0(
283
292
  database_name=global_string_database_name,
284
293
  schema_name=global_string_schema_name,
285
- table_name=UserCredential.__tablename__,
294
+ table_name=UserProfile.__tablename__,
286
295
  filters=FiltersV0(
287
- root={UserCredential.user_id.name: FilterConditionsV0(eq=user_id)}
296
+ root={UserProfile.user_id.name: FilterConditionsV0(eq=user_id)}
288
297
  ),
289
298
  )["data"]["main"]
290
299
  )
@@ -309,8 +318,8 @@ async def get_user_details_v0(
309
318
  return_this = {
310
319
  "user_id": user_id,
311
320
  "credentials": {
312
- "username": local_list_response_user_credentials[0][
313
- UserCredential.user_credential_username.name
321
+ "username": local_list_response_user_profile[0][
322
+ UserProfile.user_profile_username.name
314
323
  ],
315
324
  },
316
325
  "apps": [
@@ -539,22 +548,20 @@ async def login_username_v0(body: LoginUsernameV0):
539
548
  validation
540
549
  """
541
550
  # validation for username
542
- local_list_authentication_user_response = global_object_square_database_helper.get_rows_v0(
543
- database_name=global_string_database_name,
544
- schema_name=global_string_schema_name,
545
- table_name=UserCredential.__tablename__,
546
- filters=FiltersV0(
547
- root={
548
- UserCredential.user_credential_username.name: FilterConditionsV0(
549
- eq=username
550
- )
551
- }
552
- ),
553
- )[
554
- "data"
555
- ][
556
- "main"
557
- ]
551
+ local_list_authentication_user_response = (
552
+ global_object_square_database_helper.get_rows_v0(
553
+ database_name=global_string_database_name,
554
+ schema_name=global_string_schema_name,
555
+ table_name=UserProfile.__tablename__,
556
+ filters=FiltersV0(
557
+ root={
558
+ UserProfile.user_profile_username.name: FilterConditionsV0(
559
+ eq=username
560
+ )
561
+ }
562
+ ),
563
+ )["data"]["main"]
564
+ )
558
565
  if len(local_list_authentication_user_response) != 1:
559
566
  output_content = get_api_output_in_standard_format(
560
567
  message=messages["INCORRECT_USERNAME"],
@@ -840,9 +847,7 @@ async def logout_v0(
840
847
  )
841
848
  # validating if the refresh token is valid, active and of the same user.
842
849
  try:
843
- local_dict_refresh_token_payload = get_jwt_payload(
844
- refresh_token, config_str_secret_key_for_refresh_token
845
- )
850
+ _ = get_jwt_payload(refresh_token, config_str_secret_key_for_refresh_token)
846
851
  except Exception as error:
847
852
  output_content = get_api_output_in_standard_format(
848
853
  message=messages["INCORRECT_REFRESH_TOKEN"],
@@ -1102,22 +1107,20 @@ async def update_username_v0(
1102
1107
  )
1103
1108
 
1104
1109
  # validate new username
1105
- local_list_user_credentials_response = global_object_square_database_helper.get_rows_v0(
1106
- database_name=global_string_database_name,
1107
- schema_name=global_string_schema_name,
1108
- table_name=UserCredential.__tablename__,
1109
- filters=FiltersV0(
1110
- root={
1111
- UserCredential.user_credential_username.name: FilterConditionsV0(
1112
- eq=new_username
1113
- ),
1114
- }
1115
- ),
1116
- )[
1117
- "data"
1118
- ][
1119
- "main"
1120
- ]
1110
+ local_list_user_credentials_response = (
1111
+ global_object_square_database_helper.get_rows_v0(
1112
+ database_name=global_string_database_name,
1113
+ schema_name=global_string_schema_name,
1114
+ table_name=UserProfile.__tablename__,
1115
+ filters=FiltersV0(
1116
+ root={
1117
+ UserProfile.user_profile_username.name: FilterConditionsV0(
1118
+ eq=new_username
1119
+ ),
1120
+ }
1121
+ ),
1122
+ )["data"]["main"]
1123
+ )
1121
1124
  if len(local_list_user_credentials_response) != 0:
1122
1125
  output_content = get_api_output_in_standard_format(
1123
1126
  message=messages["USERNAME_ALREADY_EXISTS"],
@@ -1134,14 +1137,14 @@ async def update_username_v0(
1134
1137
  global_object_square_database_helper.edit_rows_v0(
1135
1138
  database_name=global_string_database_name,
1136
1139
  schema_name=global_string_schema_name,
1137
- table_name=UserCredential.__tablename__,
1140
+ table_name=UserProfile.__tablename__,
1138
1141
  filters=FiltersV0(
1139
1142
  root={
1140
- UserCredential.user_id.name: FilterConditionsV0(eq=user_id),
1143
+ UserProfile.user_id.name: FilterConditionsV0(eq=user_id),
1141
1144
  }
1142
1145
  ),
1143
1146
  data={
1144
- UserCredential.user_credential_username.name: new_username,
1147
+ UserProfile.user_profile_username.name: new_username,
1145
1148
  },
1146
1149
  )
1147
1150
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: square-authentication
3
- Version: 5.1.1
3
+ Version: 5.1.2
4
4
  Summary: authentication layer for my personal server.
5
5
  Home-page: https://github.com/thepmsquare/square_authentication
6
6
  Author: thePmSquare
@@ -23,7 +23,7 @@ Requires-Dist: cryptography>=42.0.7
23
23
  Requires-Dist: square-commons>=1.0.0
24
24
  Requires-Dist: square-logger>=1.0.0
25
25
  Requires-Dist: square-database-helper>=2.0.0
26
- Requires-Dist: square-database-structure>=1.0.0
26
+ Requires-Dist: square-database-structure>=2.3.1
27
27
  Requires-Dist: pytest>=8.0.0
28
28
  Requires-Dist: httpx>=0.27.2
29
29
 
@@ -45,6 +45,11 @@ pip install square_authentication
45
45
 
46
46
  ## changelog
47
47
 
48
+ ### v5.1.2
49
+
50
+ - bump square_database_structure>=2.3.1.
51
+ - change logic to read username from profile instead of credentials table.
52
+
48
53
  ### v5.1.1
49
54
 
50
55
  - add logger decorator in all functions.
@@ -6,12 +6,12 @@ square_authentication/data/config.ini,sha256=_740RvKpL5W2bUDGwZ7ePwuP-mAasr5cXXB
6
6
  square_authentication/pydantic_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  square_authentication/pydantic_models/core.py,sha256=qeNETcJv7mnRKGhATOW2bg0NlHuyzvot1dZ1b1qqhwU,610
8
8
  square_authentication/routes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- square_authentication/routes/core.py,sha256=CFjlsTF8XXcsImJG_3LVBfncG9RiENYnAQ4Msve-CM4,55858
9
+ square_authentication/routes/core.py,sha256=uxVjiToeUrGfrpCJPIRFvyYFEvvHmOZn7Sw5OSFGnUA,56183
10
10
  square_authentication/routes/utility.py,sha256=ocLWj39JbKVOxgyTsM0xBUgTpHFmKIvvaT3UnjFvuOY,1783
11
11
  square_authentication/utils/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
12
  square_authentication/utils/encryption.py,sha256=amlTNbGvq59eFLX6pq084UDLI3deM-urLjb4fOYIeNw,2023
13
13
  square_authentication/utils/token.py,sha256=2psHT6CGqQLmkhsPHVYS8_2jEjN96J9gLAM4lB_fa88,678
14
- square_authentication-5.1.1.dist-info/METADATA,sha256=9mvUZaxzbuRB-tnyeUTyzTQ4vFrXIejx2ybKTuP57tQ,3836
15
- square_authentication-5.1.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
16
- square_authentication-5.1.1.dist-info/top_level.txt,sha256=wDssVJIl9KIEJPj5rR3rv4uRI7yCndMBrvHd_6BGXQA,22
17
- square_authentication-5.1.1.dist-info/RECORD,,
14
+ square_authentication-5.1.2.dist-info/METADATA,sha256=yn52G_RVeuzHkPI4jqAsm2nWnEeACnVe-sGssh-t2rs,3965
15
+ square_authentication-5.1.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
16
+ square_authentication-5.1.2.dist-info/top_level.txt,sha256=wDssVJIl9KIEJPj5rR3rv4uRI7yCndMBrvHd_6BGXQA,22
17
+ square_authentication-5.1.2.dist-info/RECORD,,