square-authentication 6.0.1__tar.gz → 6.0.3__tar.gz

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.
Files changed (24) hide show
  1. {square_authentication-6.0.1 → square_authentication-6.0.3}/PKG-INFO +11 -2
  2. {square_authentication-6.0.1 → square_authentication-6.0.3}/README.md +9 -0
  3. {square_authentication-6.0.1 → square_authentication-6.0.3}/setup.py +2 -2
  4. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/routes/profile.py +51 -37
  5. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication.egg-info/PKG-INFO +11 -2
  6. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication.egg-info/requires.txt +1 -1
  7. {square_authentication-6.0.1 → square_authentication-6.0.3}/setup.cfg +0 -0
  8. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/__init__.py +0 -0
  9. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/configuration.py +0 -0
  10. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/data/config.ini +0 -0
  11. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/main.py +0 -0
  12. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/messages.py +0 -0
  13. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/pydantic_models/__init__.py +0 -0
  14. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/pydantic_models/core.py +0 -0
  15. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/routes/__init__.py +0 -0
  16. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/routes/core.py +0 -0
  17. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/routes/utility.py +0 -0
  18. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/utils/__init__.py +0 -0
  19. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/utils/encryption.py +0 -0
  20. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication/utils/token.py +0 -0
  21. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication.egg-info/SOURCES.txt +0 -0
  22. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication.egg-info/dependency_links.txt +0 -0
  23. {square_authentication-6.0.1 → square_authentication-6.0.3}/square_authentication.egg-info/top_level.txt +0 -0
  24. {square_authentication-6.0.1 → square_authentication-6.0.3}/tests/test_1.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: square_authentication
3
- Version: 6.0.1
3
+ Version: 6.0.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: square_commons>=1.0.0
23
23
  Requires-Dist: square_logger>=2.0.0
24
24
  Requires-Dist: square_database_helper>=2.0.0
25
25
  Requires-Dist: square_database_structure>=2.3.1
26
- Requires-Dist: square_file_store_helper>=2.1.0
26
+ Requires-Dist: square_file_store_helper>=3.0.0
27
27
  Requires-Dist: pytest>=8.0.0
28
28
  Requires-Dist: httpx>=0.27.2
29
29
  Dynamic: author
@@ -53,6 +53,15 @@ pip install square_authentication
53
53
 
54
54
  ## changelog
55
55
 
56
+ ### v6.0.3
57
+
58
+ - make profile photo upload optional in update_profile_photo/v0, to enable users to remove their profile photo.
59
+
60
+ ### v6.0.2
61
+
62
+ - bump square_file_store_helper to >=3.0.0.
63
+ - use upload_file_using_tuple_v0 instead of upload_file_using_path_v0 in update_profile_photo/v0.
64
+
56
65
  ### v6.0.1
57
66
 
58
67
  - delete previous profile photo from file store after successfully updating profile photo.
@@ -16,6 +16,15 @@ pip install square_authentication
16
16
 
17
17
  ## changelog
18
18
 
19
+ ### v6.0.3
20
+
21
+ - make profile photo upload optional in update_profile_photo/v0, to enable users to remove their profile photo.
22
+
23
+ ### v6.0.2
24
+
25
+ - bump square_file_store_helper to >=3.0.0.
26
+ - use upload_file_using_tuple_v0 instead of upload_file_using_path_v0 in update_profile_photo/v0.
27
+
19
28
  ### v6.0.1
20
29
 
21
30
  - delete previous profile photo from file store after successfully updating profile photo.
@@ -4,7 +4,7 @@ package_name = "square_authentication"
4
4
 
5
5
  setup(
6
6
  name=package_name,
7
- version="6.0.1",
7
+ version="6.0.3",
8
8
  packages=find_packages(),
9
9
  package_data={
10
10
  package_name: ["data/*"],
@@ -22,7 +22,7 @@ setup(
22
22
  "square_logger>=2.0.0",
23
23
  "square_database_helper>=2.0.0",
24
24
  "square_database_structure>=2.3.1",
25
- "square_file_store_helper>=2.1.0",
25
+ "square_file_store_helper>=3.0.0",
26
26
  "pytest>=8.0.0",
27
27
  "httpx>=0.27.2",
28
28
  ],
@@ -1,5 +1,4 @@
1
- import os
2
- from typing import Annotated
1
+ from typing import Annotated, Optional
3
2
 
4
3
  from fastapi import APIRouter, HTTPException, status, Header, UploadFile
5
4
  from fastapi.responses import JSONResponse
@@ -28,7 +27,7 @@ router = APIRouter(
28
27
  @global_object_square_logger.auto_logger()
29
28
  async def update_profile_photo_v0(
30
29
  access_token: Annotated[str, Header()],
31
- profile_photo: UploadFile,
30
+ profile_photo: Optional[UploadFile] = None,
32
31
  ):
33
32
 
34
33
  try:
@@ -51,7 +50,9 @@ async def update_profile_photo_v0(
51
50
  user_id = local_dict_access_token_payload["user_id"]
52
51
 
53
52
  # validate file format
54
- if not profile_photo.filename.endswith((".jpg", ".jpeg", ".png")):
53
+ if profile_photo and not profile_photo.filename.endswith(
54
+ (".jpg", ".jpeg", ".png")
55
+ ):
55
56
  output_content = get_api_output_in_standard_format(
56
57
  message=messages["INVALID_FILE_FORMAT"]
57
58
  )
@@ -62,7 +63,9 @@ async def update_profile_photo_v0(
62
63
 
63
64
  # validate file size
64
65
  file_size_limit_in_mib = 5
65
- if profile_photo.size > (file_size_limit_in_mib * 1024 * 1024):
66
+ if profile_photo and profile_photo.size > (
67
+ file_size_limit_in_mib * 1024 * 1024
68
+ ):
66
69
  output_content = get_api_output_in_standard_format(
67
70
  message=messages["FILE_SIZE_EXCEEDS_LIMIT"]
68
71
  )
@@ -73,24 +76,6 @@ async def update_profile_photo_v0(
73
76
  """
74
77
  main process
75
78
  """
76
- # uploading to square file store
77
- destination_path = os.path.join(
78
- "temp", user_id, "profile_photo", profile_photo.filename
79
- )
80
- os.makedirs(os.path.dirname(destination_path), exist_ok=True)
81
- with open(destination_path, "wb") as out_file:
82
- content = await profile_photo.read()
83
- out_file.write(content)
84
-
85
- file_upload_response = (
86
- global_object_square_file_store_helper.upload_file_using_file_path_v0(
87
- file_path=destination_path,
88
- system_relative_path="global/users/profile_photos",
89
- )
90
- )
91
- os.remove(destination_path)
92
-
93
- # adding file storage token to user profile
94
79
  old_profile_photo_response = global_object_square_database_helper.get_rows_v0(
95
80
  database_name=global_string_database_name,
96
81
  schema_name=global_string_schema_name,
@@ -103,20 +88,49 @@ async def update_profile_photo_v0(
103
88
  old_profile_photo_token = old_profile_photo_response["data"]["main"][0][
104
89
  "user_profile_photo_storage_token"
105
90
  ]
106
- profile_update_response = global_object_square_database_helper.edit_rows_v0(
107
- data={
108
- UserProfile.user_profile_photo_storage_token.name: file_upload_response[
109
- "data"
110
- ]["main"]
111
- },
112
- filters=FiltersV0(
113
- root={UserProfile.user_id.name: FilterConditionsV0(eq=user_id)}
114
- ),
115
- database_name=global_string_database_name,
116
- schema_name=global_string_schema_name,
117
- table_name=UserProfile.__tablename__,
118
- apply_filters=True,
119
- )
91
+
92
+ if profile_photo:
93
+ # uploading to square file store
94
+ file_upload_response = (
95
+ global_object_square_file_store_helper.upload_file_using_tuple_v0(
96
+ file=(
97
+ profile_photo.filename,
98
+ profile_photo.file,
99
+ profile_photo.content_type,
100
+ ),
101
+ system_relative_path="global/users/profile_photos",
102
+ )
103
+ )
104
+ # updating user profile
105
+ profile_update_response = global_object_square_database_helper.edit_rows_v0(
106
+ data={
107
+ UserProfile.user_profile_photo_storage_token.name: file_upload_response[
108
+ "data"
109
+ ][
110
+ "main"
111
+ ]
112
+ },
113
+ filters=FiltersV0(
114
+ root={UserProfile.user_id.name: FilterConditionsV0(eq=user_id)}
115
+ ),
116
+ database_name=global_string_database_name,
117
+ schema_name=global_string_schema_name,
118
+ table_name=UserProfile.__tablename__,
119
+ apply_filters=True,
120
+ )
121
+ else:
122
+ # updating user profile
123
+ profile_update_response = global_object_square_database_helper.edit_rows_v0(
124
+ data={UserProfile.user_profile_photo_storage_token.name: None},
125
+ filters=FiltersV0(
126
+ root={UserProfile.user_id.name: FilterConditionsV0(eq=user_id)}
127
+ ),
128
+ database_name=global_string_database_name,
129
+ schema_name=global_string_schema_name,
130
+ table_name=UserProfile.__tablename__,
131
+ apply_filters=True,
132
+ )
133
+
120
134
  if old_profile_photo_token:
121
135
  global_object_square_file_store_helper.delete_file_v0(
122
136
  [old_profile_photo_token]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: square_authentication
3
- Version: 6.0.1
3
+ Version: 6.0.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: square_commons>=1.0.0
23
23
  Requires-Dist: square_logger>=2.0.0
24
24
  Requires-Dist: square_database_helper>=2.0.0
25
25
  Requires-Dist: square_database_structure>=2.3.1
26
- Requires-Dist: square_file_store_helper>=2.1.0
26
+ Requires-Dist: square_file_store_helper>=3.0.0
27
27
  Requires-Dist: pytest>=8.0.0
28
28
  Requires-Dist: httpx>=0.27.2
29
29
  Dynamic: author
@@ -53,6 +53,15 @@ pip install square_authentication
53
53
 
54
54
  ## changelog
55
55
 
56
+ ### v6.0.3
57
+
58
+ - make profile photo upload optional in update_profile_photo/v0, to enable users to remove their profile photo.
59
+
60
+ ### v6.0.2
61
+
62
+ - bump square_file_store_helper to >=3.0.0.
63
+ - use upload_file_using_tuple_v0 instead of upload_file_using_path_v0 in update_profile_photo/v0.
64
+
56
65
  ### v6.0.1
57
66
 
58
67
  - delete previous profile photo from file store after successfully updating profile photo.
@@ -10,6 +10,6 @@ square_commons>=1.0.0
10
10
  square_logger>=2.0.0
11
11
  square_database_helper>=2.0.0
12
12
  square_database_structure>=2.3.1
13
- square_file_store_helper>=2.1.0
13
+ square_file_store_helper>=3.0.0
14
14
  pytest>=8.0.0
15
15
  httpx>=0.27.2