Skip to content

Commit e5cb2cb

Browse files
committed
Validate wifi credentials
1 parent d26e232 commit e5cb2cb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

adafruit_portalbase/network.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,14 @@ def connect(self, max_attempts=10):
385385
raise TypeError(
386386
"'networks' must be a list/tuple of dicts of 'ssid' and 'password'"
387387
)
388+
389+
self._wifi_credentials = list(filter(
390+
lambda credentials: isinstance(credentials, (list, tuple)) and "ssid" in credentials and "password" in credentials and type(credentials["ssid"]) is str and type(credentials["password"]) is str and len(credentials["ssid"]) and len(credentials["password"]),
391+
self._wifi_credentials
392+
))
393+
if not len(self._wifi_credentials):
394+
self._wifi_credentials = None
395+
raise OSError("No valid wifi credentials provided")
388396

389397
for credentials in self._wifi_credentials:
390398
self._wifi.neo_status(STATUS_CONNECTING)

0 commit comments

Comments
 (0)