Skip to content

Commit

Permalink
Encode username/password
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Apr 12, 2023
1 parent 6b2c60d commit 33454f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pyhon/connection/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import urllib
from pprint import pformat
from urllib import parse
from urllib.parse import quote

from yarl import URL

Expand Down Expand Up @@ -113,8 +114,8 @@ async def _login(self, fw_uid, loaded, login_url):
"descriptor": "apex://LightningLoginCustomController/ACTION$login",
"callingDescriptor": "markup://c:loginForm",
"params": {
"username": self._email,
"password": self._password,
"username": quote(self._email),
"password": quote(self._password),
"startUrl": parse.unquote(
login_url.split("startURL=")[-1]
).split("%3D")[0],
Expand Down
7 changes: 5 additions & 2 deletions pyhon/connection/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ class HonBaseConnectionHandler:
_HEADERS = {"user-agent": const.USER_AGENT, "Content-Type": "application/json"}

def __init__(self, session=None):
self._create_session = session is None
self._session = session
self._auth = None

async def __aenter__(self):
self._session = aiohttp.ClientSession()
return await self.create()

async def __aexit__(self, exc_type, exc_val, exc_tb):
await self.close()

async def create(self):
if self._create_session:
self._session = aiohttp.ClientSession()
return self

@asynccontextmanager
Expand All @@ -41,7 +43,8 @@ async def post(self, *args, **kwargs):
yield response

async def close(self):
await self._session.close()
if self._create_session:
await self._session.close()


class HonConnectionHandler(HonBaseConnectionHandler):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="pyhOn",
version="0.7.1",
version="0.7.2",
author="Andre Basche",
description="Control hOn devices with python",
long_description=long_description,
Expand Down

0 comments on commit 33454f6

Please sign in to comment.