Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: legacy device login #6

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions library_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ async def main() -> None:

print("-" * 20)
api = VodafoneStationApi(args.router, args.username, args.password)
logged = await api.login()
logged = False
try:
logged = await api.login()
finally:
if not logged:
await api.close()
exit(1)
print("Logged:", logged)
if not logged:
await api.close()
exit(1)

print("-" * 20)
devices = await api.get_all_devices()
Expand Down
4 changes: 3 additions & 1 deletion src/aiovodafone/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ async def _login_json(self, username: str, password: str) -> bool:
if reply_json == "2":
raise AlreadyLogged

if reply_json in ["3", "4"]:
if reply_json in ["3", "4", "5"]:
raise CannotAuthenticate

return False
Expand Down Expand Up @@ -296,11 +296,13 @@ async def login(self) -> bool:
# First try with both username and password encrypted
# Second try with plain username and password encrypted
try:
_LOGGER.debug("Login first try: username[encrypted], password[encrypted]")
logged = await self._login_json(
await self._encrypt_string(self.username),
await self._encrypt_string(self.password),
)
except CannotAuthenticate:
_LOGGER.debug("Login second try: username[plain], password[encrypted]")
logged = await self._login_json(
self.username, await self._encrypt_string(self.password)
)
Expand Down