MCPcopy
hub / github.com/1Panel-dev/MaxKB / post

Method post

apps/users/views/user.py:385–402  ·  view source on GitHub ↗
(self, request: Request)

Source from the content-addressed store, hash-verified

383 @has_permissions(PermissionConstants.CHANGE_PASSWORD, RoleConstants.ADMIN, RoleConstants.USER,
384 RoleConstants.WORKSPACE_MANAGE)
385 def post(self, request: Request):
386 request_data = request.data
387 encrypted_data = request_data.get("encryptedData", "")
388 if encrypted_data:
389 try:
390 decrypted_raw = decrypt(encrypted_data)
391 # decrypt 可能返回非 JSON 字符串,防护解析异常
392 decrypted_data = json.loads(decrypted_raw) if decrypted_raw else {}
393 if isinstance(decrypted_data, dict):
394 request_data = decrypted_data
395 except Exception as e:
396 raise AppApiException(500, _("Invalid encrypted data"))
397 serializer_obj = ResetCurrentUserPassword(data=request_data)
398 if serializer_obj.reset_password(request.user.id):
399 version, get_key = Cache_Version.TOKEN.value
400 cache.delete(get_key(token=request.auth), version=version)
401 return result.success(True)
402 return result.error(_("Failed to change password"))

Callers

nothing calls this directly

Calls 8

reset_passwordMethod · 0.95
decryptFunction · 0.90
AppApiExceptionClass · 0.90
getMethod · 0.45
deleteMethod · 0.45
successMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected