square-authentication 5.1.1__py3-none-any.whl → 5.1.3__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,
@@ -73,24 +74,35 @@ async def register_username_v0(
73
74
  """
74
75
  validation
75
76
  """
76
-
77
77
  # 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
- ]
78
+ local_list_response_user_profile = (
79
+ global_object_square_database_helper.get_rows_v0(
80
+ database_name=global_string_database_name,
81
+ schema_name=global_string_schema_name,
82
+ table_name=UserProfile.__tablename__,
83
+ filters=FiltersV0(
84
+ root={
85
+ UserProfile.user_profile_username.name: FilterConditionsV0(
86
+ eq=username
87
+ )
88
+ }
89
+ ),
90
+ )["data"]["main"]
91
+ )
92
+ local_list_response_user_creds = (
93
+ global_object_square_database_helper.get_rows_v0(
94
+ database_name=global_string_database_name,
95
+ schema_name=global_string_schema_name,
96
+ table_name=UserCredential.__tablename__,
97
+ filters=FiltersV0(
98
+ root={
99
+ UserCredential.user_id.name: FilterConditionsV0(
100
+ eq=local_list_response_user_profile[0][UserProfile.user_id.name]
101
+ )
102
+ }
103
+ ),
104
+ )["data"]["main"]
105
+ )
94
106
  if len(local_list_response_user_creds) > 0:
95
107
  output_content = get_api_output_in_standard_format(
96
108
  message=messages["USERNAME_ALREADY_EXISTS"],
@@ -124,7 +136,6 @@ async def register_username_v0(
124
136
  data=[
125
137
  {
126
138
  UserCredential.user_id.name: local_str_user_id,
127
- UserCredential.user_credential_username.name: username,
128
139
  UserCredential.user_credential_hashed_password.name: local_str_hashed_password,
129
140
  }
130
141
  ],
@@ -132,6 +143,17 @@ async def register_username_v0(
132
143
  schema_name=global_string_schema_name,
133
144
  table_name=UserCredential.__tablename__,
134
145
  )
146
+ global_object_square_database_helper.insert_rows_v0(
147
+ data=[
148
+ {
149
+ UserProfile.user_id.name: local_str_user_id,
150
+ UserProfile.user_profile_username.name: username,
151
+ }
152
+ ],
153
+ database_name=global_string_database_name,
154
+ schema_name=global_string_schema_name,
155
+ table_name=UserProfile.__tablename__,
156
+ )
135
157
  if app_id is not None:
136
158
  # assign app to user
137
159
  global_object_square_database_helper.insert_rows_v0(
@@ -278,13 +300,13 @@ async def get_user_details_v0(
278
300
  root={UserApp.user_id.name: FilterConditionsV0(eq=user_id)}
279
301
  ),
280
302
  )["data"]["main"]
281
- local_list_response_user_credentials = (
303
+ local_list_response_user_profile = (
282
304
  global_object_square_database_helper.get_rows_v0(
283
305
  database_name=global_string_database_name,
284
306
  schema_name=global_string_schema_name,
285
- table_name=UserCredential.__tablename__,
307
+ table_name=UserProfile.__tablename__,
286
308
  filters=FiltersV0(
287
- root={UserCredential.user_id.name: FilterConditionsV0(eq=user_id)}
309
+ root={UserProfile.user_id.name: FilterConditionsV0(eq=user_id)}
288
310
  ),
289
311
  )["data"]["main"]
290
312
  )
@@ -309,8 +331,8 @@ async def get_user_details_v0(
309
331
  return_this = {
310
332
  "user_id": user_id,
311
333
  "credentials": {
312
- "username": local_list_response_user_credentials[0][
313
- UserCredential.user_credential_username.name
334
+ "username": local_list_response_user_profile[0][
335
+ UserProfile.user_profile_username.name
314
336
  ],
315
337
  },
316
338
  "apps": [
@@ -539,22 +561,20 @@ async def login_username_v0(body: LoginUsernameV0):
539
561
  validation
540
562
  """
541
563
  # 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
- ]
564
+ local_list_authentication_user_response = (
565
+ global_object_square_database_helper.get_rows_v0(
566
+ database_name=global_string_database_name,
567
+ schema_name=global_string_schema_name,
568
+ table_name=UserProfile.__tablename__,
569
+ filters=FiltersV0(
570
+ root={
571
+ UserProfile.user_profile_username.name: FilterConditionsV0(
572
+ eq=username
573
+ )
574
+ }
575
+ ),
576
+ )["data"]["main"]
577
+ )
558
578
  if len(local_list_authentication_user_response) != 1:
559
579
  output_content = get_api_output_in_standard_format(
560
580
  message=messages["INCORRECT_USERNAME"],
@@ -840,9 +860,7 @@ async def logout_v0(
840
860
  )
841
861
  # validating if the refresh token is valid, active and of the same user.
842
862
  try:
843
- local_dict_refresh_token_payload = get_jwt_payload(
844
- refresh_token, config_str_secret_key_for_refresh_token
845
- )
863
+ _ = get_jwt_payload(refresh_token, config_str_secret_key_for_refresh_token)
846
864
  except Exception as error:
847
865
  output_content = get_api_output_in_standard_format(
848
866
  message=messages["INCORRECT_REFRESH_TOKEN"],
@@ -1102,22 +1120,20 @@ async def update_username_v0(
1102
1120
  )
1103
1121
 
1104
1122
  # 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
- ]
1123
+ local_list_user_credentials_response = (
1124
+ global_object_square_database_helper.get_rows_v0(
1125
+ database_name=global_string_database_name,
1126
+ schema_name=global_string_schema_name,
1127
+ table_name=UserProfile.__tablename__,
1128
+ filters=FiltersV0(
1129
+ root={
1130
+ UserProfile.user_profile_username.name: FilterConditionsV0(
1131
+ eq=new_username
1132
+ ),
1133
+ }
1134
+ ),
1135
+ )["data"]["main"]
1136
+ )
1121
1137
  if len(local_list_user_credentials_response) != 0:
1122
1138
  output_content = get_api_output_in_standard_format(
1123
1139
  message=messages["USERNAME_ALREADY_EXISTS"],
@@ -1134,14 +1150,14 @@ async def update_username_v0(
1134
1150
  global_object_square_database_helper.edit_rows_v0(
1135
1151
  database_name=global_string_database_name,
1136
1152
  schema_name=global_string_schema_name,
1137
- table_name=UserCredential.__tablename__,
1153
+ table_name=UserProfile.__tablename__,
1138
1154
  filters=FiltersV0(
1139
1155
  root={
1140
- UserCredential.user_id.name: FilterConditionsV0(eq=user_id),
1156
+ UserProfile.user_id.name: FilterConditionsV0(eq=user_id),
1141
1157
  }
1142
1158
  ),
1143
1159
  data={
1144
- UserCredential.user_credential_username.name: new_username,
1160
+ UserProfile.user_profile_username.name: new_username,
1145
1161
  },
1146
1162
  )
1147
1163
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: square-authentication
3
- Version: 5.1.1
3
+ Version: 5.1.3
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,15 @@ pip install square_authentication
45
45
 
46
46
  ## changelog
47
47
 
48
+ ### v5.1.3
49
+
50
+ - bugfix in login_username/v0 (getting creds from correct table).
51
+
52
+ ### v5.1.2
53
+
54
+ - bump square_database_structure>=2.3.1.
55
+ - change logic to read username from profile instead of credentials table.
56
+
48
57
  ### v5.1.1
49
58
 
50
59
  - 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=AM_OiqSndZ6-4c28QnEICXx6WZOms9UzHUYk3wBv5ZA,56795
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.3.dist-info/METADATA,sha256=9W4cTp_4-DIGzWMg4j0601MaeYHCw97gsURKgHG5U0I,4044
15
+ square_authentication-5.1.3.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
16
+ square_authentication-5.1.3.dist-info/top_level.txt,sha256=wDssVJIl9KIEJPj5rR3rv4uRI7yCndMBrvHd_6BGXQA,22
17
+ square_authentication-5.1.3.dist-info/RECORD,,