nc-user-terminator 0.1.8__tar.gz → 0.1.10__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.
Potentially problematic release.
This version of nc-user-terminator might be problematic. Click here for more details.
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/PKG-INFO +5 -1
- nc_user_terminator-0.1.10/README.md +13 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_manager/client.py +16 -8
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_terminator.egg-info/PKG-INFO +5 -1
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/pyproject.toml +1 -1
- nc_user_terminator-0.1.8/README.md +0 -9
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_manager/__init__.py +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_manager/cache.py +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_manager/exceptions.py +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_manager/models.py +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_manager/utils.py +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_terminator.egg-info/SOURCES.txt +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_terminator.egg-info/dependency_links.txt +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_terminator.egg-info/requires.txt +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_terminator.egg-info/top_level.txt +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/setup.cfg +0 -0
- {nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nc-user-terminator
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.10
|
|
4
4
|
Summary: OAuth client wrapper for multi-tenant projects
|
|
5
5
|
Author: bw_song
|
|
6
6
|
Author-email: m132777096902@gmail.com
|
|
@@ -19,3 +19,7 @@ Dynamic: requires-python
|
|
|
19
19
|
- 映射host
|
|
20
20
|
+ v0.1.8
|
|
21
21
|
- 调整相对路径
|
|
22
|
+
+ v0.1.9
|
|
23
|
+
- 修改缓存配置
|
|
24
|
+
+ v0.1.10
|
|
25
|
+
- 获取用户信息,本地缓存配置
|
|
@@ -14,8 +14,8 @@ DEFAULT_TTL = 3600
|
|
|
14
14
|
class OAuthClient:
|
|
15
15
|
def __init__(
|
|
16
16
|
self,
|
|
17
|
-
base_url: Optional[str],
|
|
18
17
|
product_code: str,
|
|
18
|
+
base_url: Optional[str] = None,
|
|
19
19
|
redirect_url: Optional[str] = None,
|
|
20
20
|
single_session: bool = False,
|
|
21
21
|
cache: Optional[BaseCache] = None,
|
|
@@ -219,19 +219,23 @@ class OAuthClient:
|
|
|
219
219
|
return UserResponse(res_dict)
|
|
220
220
|
|
|
221
221
|
async def say_my_name_async(self, token: str) -> UserResponse:
|
|
222
|
-
if not self._async_cache:
|
|
223
|
-
raise RuntimeError("异步方法只支持异步缓存,请传入 async_cache")
|
|
224
|
-
|
|
225
222
|
"""异步获取当前用户"""
|
|
226
223
|
key = f"user:{token}"
|
|
227
|
-
|
|
224
|
+
if self._async_cache:
|
|
225
|
+
data = await self._cache.get(key)
|
|
226
|
+
else:
|
|
227
|
+
data = self._cache.get(key)
|
|
228
|
+
|
|
228
229
|
if data:
|
|
229
230
|
return UserResponse(data)
|
|
230
231
|
|
|
231
232
|
headers = self._headers({"Authorization": f"Bearer {token}"})
|
|
232
233
|
res_dict = await self._arequest("GET", f"{self._base_url}/api/me", headers=headers)
|
|
233
234
|
if res_dict.get("success", True):
|
|
234
|
-
|
|
235
|
+
if self._async_cache:
|
|
236
|
+
await self._cache_user_async(token, res_dict)
|
|
237
|
+
else:
|
|
238
|
+
self._cache_user(token, res_dict)
|
|
235
239
|
|
|
236
240
|
return UserResponse(res_dict)
|
|
237
241
|
|
|
@@ -267,8 +271,12 @@ class OAuthClient:
|
|
|
267
271
|
headers = self._headers({"Authorization": f"Bearer {token}"})
|
|
268
272
|
resp = await self._arequest("POST", f"{self._base_url}/api/auth/logout", headers=headers)
|
|
269
273
|
|
|
270
|
-
|
|
271
|
-
|
|
274
|
+
if self._async_cache:
|
|
275
|
+
data = await self._cache.get(f"user:{token}")
|
|
276
|
+
await self._uncache_user_async(token, data)
|
|
277
|
+
else:
|
|
278
|
+
data = self._cache.get(f"user:{token}")
|
|
279
|
+
self._uncache_user(token, data)
|
|
272
280
|
return resp
|
|
273
281
|
|
|
274
282
|
async def main():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nc-user-terminator
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.10
|
|
4
4
|
Summary: OAuth client wrapper for multi-tenant projects
|
|
5
5
|
Author: bw_song
|
|
6
6
|
Author-email: m132777096902@gmail.com
|
|
@@ -19,3 +19,7 @@ Dynamic: requires-python
|
|
|
19
19
|
- 映射host
|
|
20
20
|
+ v0.1.8
|
|
21
21
|
- 调整相对路径
|
|
22
|
+
+ v0.1.9
|
|
23
|
+
- 修改缓存配置
|
|
24
|
+
+ v0.1.10
|
|
25
|
+
- 获取用户信息,本地缓存配置
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_terminator.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_terminator.egg-info/requires.txt
RENAMED
|
File without changes
|
{nc_user_terminator-0.1.8 → nc_user_terminator-0.1.10}/nc_user_terminator.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|