Skip to content

Commit b94af4f

Browse files
authored
Merge pull request #74 from pyalarmdotcom/fix-2fa-error
Fixes alarmdotcom/185
2 parents 2c704c2 + 112e49e commit b94af4f

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ repos:
8383
entry: pylint
8484
language: system
8585
types: [python]
86-
exclude: (.vscode|.devcontainer|.github)
86+
exclude: (.vscode|.devcontainer|.mypy_cache|custom_components/nyc311/__pycache__|pylint)
8787
args:
8888
- --output-format=colorized
89-
- -d W0511 # ignores TODO messages when running via pre-commit
89+
- -d W0511
90+
- --fail-on=all

pyalarmdotcomajax/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from .extensions import ConfigurationOption
3838
from .extensions import ExtendedProperties
3939

40-
__version__ = "0.4.6"
40+
__version__ = "0.4.7"
4141

4242
log = logging.getLogger(__name__)
4343

@@ -97,8 +97,6 @@ class AlarmController:
9797
LOGIN_2FA_REQUEST_OTP_SMS_URL_TEMPLATE = "{}web/api/twoFactorAuthentication/twoFactorAuthentications/{}/sendTwoFactorAuthenticationCode"
9898
LOGIN_2FA_REQUEST_OTP_EMAIL_URL_TEMPLATE = "{}web/api/twoFactorAuthentication/twoFactorAuthentications/{}/sendTwoFactorAuthenticationCodeViaEmail"
9999

100-
IDENTITIES_2FA_NAG_URL_TEMPLATE = "{}system-install/api/identity"
101-
102100
VIEWSTATE_FIELD = "__VIEWSTATE"
103101
VIEWSTATEGENERATOR_FIELD = "__VIEWSTATEGENERATOR"
104102
EVENTVALIDATION_FIELD = "__EVENTVALIDATION"
@@ -1079,7 +1077,10 @@ async def _async_login_and_get_key(self) -> None:
10791077
raise AuthenticationFailed("Invalid username and password.")
10801078

10811079
# If Alarm.com is warning us that we'll have to set up two factor authentication soon, alert caller.
1082-
if re.search("system-install", str(resp.url)) is not None:
1080+
if (
1081+
re.search("concurrent-two-factor-authentication", str(resp.url))
1082+
is not None
1083+
):
10831084
raise NagScreen("Encountered 2FA nag screen.")
10841085

10851086
self._ajax_headers["ajaxrequestuniquekey"] = resp.cookies["afg"].value

pyalarmdotcomajax/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,6 @@ def main() -> None:
584584
if platform.system() == "Windows" and hasattr(
585585
asyncio, "WindowsSelectorEventLoopPolicy"
586586
):
587-
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # type: ignore
587+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
588588

589589
asyncio.run(cli())

requirements-dev.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
pre-commit >= 2.17.0
2-
pylint-strict-informational==0.1
3-
pytest==7.2.0
4-
aioresponses==0.7.3
5-
pytest-asyncio==0.20.3
6-
deepdiff==6.2.1
2+
pytest>=7.2.0
3+
aioresponses>=0.7.3
4+
pytest-asyncio>=0.19.0
5+
deepdiff>=6.2.1
76
beautifulsoup4 >= 4.10.0
87
aiohttp >= 3.8.1
9-
python-dateutil == 2.8.2
10-
termcolor == 2.1.1
8+
python-dateutil >= 2.8.2
9+
termcolor >= 2.1.1

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ python_requires = >=3.9
3131
install_requires =
3232
beautifulsoup4 >= 4.10.0
3333
aiohttp >= 3.8.1
34-
python-dateutil == 2.8.2
35-
termcolor == 1.1.0
34+
python-dateutil >= 2.8.2
35+
termcolor >= 2.1.1
3636

3737
[options.entry_points]
3838
console_scripts =

0 commit comments

Comments
 (0)