Skip to content

Commit cf5deff

Browse files
committed
add handling for unauthorized access attempts
this came up during interacting with the backup api with a read-only user
1 parent 8ffbd29 commit cf5deff

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ubiquiti/unifi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ def __exit__(self, *args):
6161

6262
def _check_status_code(self,code):
6363
status_codes = {400: "Invalid credentials",
64-
401: "Invalid login, or login has expired"}
64+
401: "Invalid login, or login has expired",
65+
403: "Current user not authorized to perform action"}
6566
if code == 401:
6667
try:
6768
self.login()
6869
except LoggedInException:
70+
raise LoggedInException(status_codes[code])
6971
elif code in status_codes:
7072
raise LoggedInException(status_codes[code])
7173

0 commit comments

Comments
 (0)