user-context-remote 0.0.32__tar.gz → 0.0.34__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.
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/PKG-INFO +1 -1
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/setup.py +1 -1
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote/src/user_context.py +63 -40
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote.egg-info/PKG-INFO +1 -1
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/README.md +0 -0
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/pyproject.toml +0 -0
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/setup.cfg +0 -0
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote/src/__init__.py +0 -0
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote.egg-info/SOURCES.txt +0 -0
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote.egg-info/dependency_links.txt +0 -0
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote.egg-info/requires.txt +0 -0
- {user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote.egg-info/top_level.txt +0 -0
|
@@ -12,7 +12,7 @@ with open('README.md') as f:
|
|
|
12
12
|
|
|
13
13
|
setuptools.setup(
|
|
14
14
|
name='user-context-remote',
|
|
15
|
-
version='0.0.
|
|
15
|
+
version='0.0.34', # https://pypi.org/project/user-context-remote/
|
|
16
16
|
author="Circles",
|
|
17
17
|
author_email="info@circles.life",
|
|
18
18
|
# TODO: Please update the description and delete this line
|
{user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote/src/user_context.py
RENAMED
|
@@ -40,7 +40,7 @@ class UserContext:
|
|
|
40
40
|
self.real_display_name = None
|
|
41
41
|
if (user_identifier is not None and password is not None):
|
|
42
42
|
self.user_JWT = None
|
|
43
|
-
data = self.
|
|
43
|
+
data = self._authenticate_by_user_identification_and_password(
|
|
44
44
|
user_identifier, password)
|
|
45
45
|
else:
|
|
46
46
|
self.user_JWT = user_JWT
|
|
@@ -48,89 +48,109 @@ class UserContext:
|
|
|
48
48
|
self.get_user_data_login_response(validate_jwt_response=data)
|
|
49
49
|
|
|
50
50
|
@staticmethod
|
|
51
|
-
def
|
|
52
|
-
|
|
51
|
+
def login_using_user_identification_and_password(user_identifier: str = None, password: str = None):
|
|
52
|
+
LOGIN_USING_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME = "login_using_user_identification_and_password"
|
|
53
|
+
MiniLogger.start(LOGIN_USING_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME, object={"username": user_identifier, "password": password})
|
|
53
54
|
if UserContext._instance is None:
|
|
54
55
|
if user_identifier is None:
|
|
55
|
-
|
|
56
|
+
try:
|
|
57
|
+
user_identifier = os.getenv("PRODUCT_USER_IDENTIFIER")
|
|
58
|
+
except Exception as e:
|
|
59
|
+
MiniLogger.error("Exception missing PRODUCT_USER_IDENTIFIER in .env file - ERROR - " + str(e))
|
|
56
60
|
if password is None:
|
|
57
|
-
|
|
61
|
+
try:
|
|
62
|
+
password = os.getenv("PRODUCT_PASSWORD")
|
|
63
|
+
except Exception as e:
|
|
64
|
+
MiniLogger.error("Exception missing PRODUCT_PASSWORD in .env file - ERROE -" + str(e))
|
|
58
65
|
if user_identifier is None or password is None or user_identifier == "" or password == "":
|
|
59
66
|
# To support cases when there is no PRODUCT_USERNAME and PRODUCT_PASSWORD in the deployment.
|
|
60
67
|
return None
|
|
61
68
|
UserContext._instance = UserContext(
|
|
62
69
|
user_identifier=user_identifier, password=password)
|
|
63
70
|
user = UserContext._instance
|
|
64
|
-
|
|
71
|
+
MiniLogger.end(LOGIN_USING_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME,object={"user": str(user)})
|
|
65
72
|
return user
|
|
66
73
|
|
|
67
74
|
@staticmethod
|
|
68
75
|
def login_using_jwt(user_JWT: str = None):
|
|
69
|
-
|
|
76
|
+
LOGIN_USING_JWT_METHOD_NAME = "login_using_jwt"
|
|
77
|
+
MiniLogger.start(LOGIN_USING_JWT_METHOD_NAME ,object={"user_JWT": user_JWT})
|
|
70
78
|
if UserContext._instance is None and user_JWT is not None:
|
|
71
79
|
UserContext._instance = UserContext(user_JWT=user_JWT)
|
|
72
80
|
user = UserContext._instance
|
|
73
|
-
|
|
81
|
+
MiniLogger.end(LOGIN_USING_JWT_METHOD_NAME,object={"user": str(user)})
|
|
74
82
|
return user
|
|
75
83
|
|
|
76
84
|
def _set_real_user_id(self, user_id: int) -> None:
|
|
77
|
-
|
|
85
|
+
_SET_REAL_USER_ID_METHOD_NAME = "_set_real_user_id"
|
|
86
|
+
MiniLogger.start(_SET_REAL_USER_ID_METHOD_NAME,object={"user_id": user_id})
|
|
78
87
|
self.real_user_id = user_id
|
|
79
|
-
|
|
88
|
+
MiniLogger.end(_SET_REAL_USER_ID_METHOD_NAME)
|
|
80
89
|
|
|
81
90
|
def _set_real_profile_id(self, profile_id: int) -> None:
|
|
82
|
-
|
|
91
|
+
_SET_REAL_PROFILE_ID_METHOD_NAME = "_set_real_profile_id"
|
|
92
|
+
MiniLogger.start(_SET_REAL_PROFILE_ID_METHOD_NAME,object={"profile_id": profile_id})
|
|
83
93
|
self.real_profile_id = profile_id
|
|
84
|
-
|
|
94
|
+
MiniLogger.end(_SET_REAL_PROFILE_ID_METHOD_NAME)
|
|
85
95
|
|
|
86
96
|
def get_real_user_id(self) -> int:
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
GET_REAL_USER_ID_METHOD_NAME = "get_real_user_id"
|
|
98
|
+
MiniLogger.start(GET_REAL_USER_ID_METHOD_NAME)
|
|
99
|
+
MiniLogger.end(GET_REAL_USER_ID_METHOD_NAME,object={"user_id": self.real_user_id})
|
|
89
100
|
return self.real_user_id
|
|
90
101
|
|
|
91
102
|
def get_real_profile_id(self) -> int:
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
GET_REAL_PROFILE_ID_METHOD_NAME = "get_real_profile_id"
|
|
104
|
+
MiniLogger.start(GET_REAL_PROFILE_ID_METHOD_NAME)
|
|
105
|
+
MiniLogger.end(GET_REAL_PROFILE_ID_METHOD_NAME,object={"user_id": self.real_profile_id})
|
|
94
106
|
return self.real_profile_id
|
|
95
107
|
|
|
96
108
|
def get_curent_lang_code(self) -> str:
|
|
97
|
-
|
|
98
|
-
|
|
109
|
+
GET_CURENT_LANG_CODE_METHOD_NAME = "get_curent_lang_code"
|
|
110
|
+
MiniLogger.start(GET_CURENT_LANG_CODE_METHOD_NAME)
|
|
111
|
+
MiniLogger.end(GET_CURENT_LANG_CODE_METHOD_NAME,object={"language": self.lang_code})
|
|
99
112
|
return self.lang_code
|
|
100
113
|
|
|
101
114
|
def _set_current_lang_code(self, language: LangCode) -> None:
|
|
102
|
-
|
|
115
|
+
_SET_CURRENT_LANG_CODE_METHOD_NAME = "_set_current_lang_code"
|
|
116
|
+
MiniLogger.start(_SET_CURRENT_LANG_CODE_METHOD_NAME,object={"language": language.value})
|
|
103
117
|
self.lang_code = language.value
|
|
104
|
-
|
|
118
|
+
MiniLogger.end(_SET_CURRENT_LANG_CODE_METHOD_NAME)
|
|
105
119
|
|
|
106
120
|
def _set_real_first_name(self, first_name: str) -> None:
|
|
107
|
-
|
|
121
|
+
_SET_REAL_FIRST_NAME_METHOD_NAME = "_set_real_first_name"
|
|
122
|
+
MiniLogger.start(_SET_REAL_FIRST_NAME_METHOD_NAME,object={"first_name": first_name})
|
|
108
123
|
self.real_first_name = first_name
|
|
109
|
-
|
|
124
|
+
MiniLogger.end(_SET_REAL_FIRST_NAME_METHOD_NAME)
|
|
110
125
|
|
|
111
126
|
def _set_real_last_name(self, last_name: str) -> None:
|
|
112
|
-
|
|
127
|
+
_SET_REAL_LAST_NAME_METHOD_NAME = "_set_real_last_name"
|
|
128
|
+
MiniLogger.start(_SET_REAL_LAST_NAME_METHOD_NAME,object={"first_name": last_name})
|
|
113
129
|
self.real_last_name = last_name
|
|
114
|
-
|
|
130
|
+
MiniLogger.end(_SET_REAL_LAST_NAME_METHOD_NAME)
|
|
115
131
|
|
|
116
132
|
def get_real_first_name(self) -> str:
|
|
117
|
-
|
|
118
|
-
|
|
133
|
+
GET_REAL_FIRST_NAME_METHOD_NAME = "get_real_first_name"
|
|
134
|
+
MiniLogger.start(GET_REAL_FIRST_NAME_METHOD_NAME)
|
|
135
|
+
MiniLogger.end(GET_REAL_FIRST_NAME_METHOD_NAME,object={"first_name": self.real_first_name})
|
|
119
136
|
return self.real_first_name
|
|
120
137
|
|
|
121
138
|
def get_real_last_name(self) -> str:
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
GET_REAL_LAST_NAME_METHOD_NAME = "get_real_last_name"
|
|
140
|
+
MiniLogger.start(GET_REAL_LAST_NAME_METHOD_NAME)
|
|
141
|
+
MiniLogger.end(GET_REAL_LAST_NAME_METHOD_NAME,object={"last_name": self.real_last_name})
|
|
124
142
|
return self.real_last_name
|
|
125
143
|
|
|
126
144
|
def _set_real_name(self, name: str) -> None:
|
|
127
|
-
|
|
145
|
+
_SET_REAL_NAME_METHOD_NAME = "_set_real_name"
|
|
146
|
+
MiniLogger.start(_SET_REAL_NAME_METHOD_NAME,object={"first_name": name})
|
|
128
147
|
self.real_display_name = name
|
|
129
|
-
|
|
148
|
+
MiniLogger.end(_SET_REAL_NAME_METHOD_NAME)
|
|
130
149
|
|
|
131
150
|
def get_real_name(self) -> str:
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
GET_REAL_NAME_METHOD_NAME = "get_real_name"
|
|
152
|
+
MiniLogger.start(GET_REAL_NAME_METHOD_NAME)
|
|
153
|
+
MiniLogger.end(GET_REAL_NAME_METHOD_NAME,object={"first_name": self.real_first_name})
|
|
134
154
|
return self.real_display_name
|
|
135
155
|
|
|
136
156
|
def get_user_JWT(self) -> str:
|
|
@@ -148,8 +168,9 @@ class UserContext:
|
|
|
148
168
|
def _set_effective_profile_id(self, profile_id: int) -> None:
|
|
149
169
|
self.effective_profile_id = profile_id
|
|
150
170
|
|
|
151
|
-
def
|
|
152
|
-
|
|
171
|
+
def _authenticate_by_user_identification_and_password(self, user_identifier: str, password: str) -> str:
|
|
172
|
+
_AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME = "_authenticate_by_user_identification_and_password"
|
|
173
|
+
MiniLogger.start(_AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME,object={"email": user_identifier, "password": password})
|
|
153
174
|
try:
|
|
154
175
|
url_circlez = OurUrl()
|
|
155
176
|
url_jwt = url_circlez.endpoint_url(
|
|
@@ -166,19 +187,20 @@ class UserContext:
|
|
|
166
187
|
url=url_jwt, data=json.dumps(data, separators=(",", ":")), headers=headers
|
|
167
188
|
)
|
|
168
189
|
if output.status_code != HTTPStatus.OK:
|
|
169
|
-
|
|
190
|
+
MiniLogger.info(_AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME + " output.status_code != HTTPStatus.OK " + output.text)
|
|
170
191
|
raise Exception(output.text)
|
|
171
192
|
self.user_JWT = output.json()["data"]["token"]
|
|
172
|
-
|
|
193
|
+
MiniLogger.end(_AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME,object={"user_JWT": self.user_JWT })
|
|
173
194
|
return output
|
|
174
195
|
except Exception as exception:
|
|
175
|
-
|
|
176
|
-
"Error(Exception): user-context-remote-python _authenticate() " + str(exception)
|
|
177
|
-
|
|
178
|
-
# logger.end()
|
|
196
|
+
MiniLogger.error(
|
|
197
|
+
"Error(Exception): user-context-remote-python _authenticate() " + str(exception))
|
|
198
|
+
MiniLogger.end(_AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME)
|
|
179
199
|
raise
|
|
180
200
|
|
|
181
201
|
def _authenticate_by_user_JWT(self, user_JWT: str) -> str:
|
|
202
|
+
_AUTHENTICATE_BY_USER_JWT_METHOD_NAME = "_authenticate_by_user_JWT"
|
|
203
|
+
MiniLogger.start(_AUTHENTICATE_BY_USER_JWT_METHOD_NAME,object={"user_JWT": user_JWT})
|
|
182
204
|
url_circlez = OurUrl()
|
|
183
205
|
authentication_login_validate_jwt_url = url_circlez.endpoint_url(
|
|
184
206
|
brand_name=BRAND_NAME,
|
|
@@ -197,6 +219,7 @@ class UserContext:
|
|
|
197
219
|
MiniLogger.info(
|
|
198
220
|
"user-context-remote-python-package _authenticate_by_user_JWT() output.status_code != HTTPStatus.OK " + output.text)
|
|
199
221
|
raise Exception(output.text)
|
|
222
|
+
MiniLogger.end(_AUTHENTICATE_BY_USER_JWT_METHOD_NAME, object={"validate_jwt_response": output})
|
|
200
223
|
return output
|
|
201
224
|
|
|
202
225
|
def get_user_data_login_response(self, validate_jwt_response: str) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote/src/__init__.py
RENAMED
|
File without changes
|
{user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote.egg-info/requires.txt
RENAMED
|
File without changes
|
{user-context-remote-0.0.32 → user-context-remote-0.0.34}/user_context_remote.egg-info/top_level.txt
RENAMED
|
File without changes
|