Error handling if Pi-hole password is wrong
This commit is contained in:
parent
da65989477
commit
b23e2d93aa
4
main.py
4
main.py
@ -58,7 +58,11 @@ def loginToPihole(apiurl, phpassword):
|
||||
loginrq = session.post(url,data={"pw": phpassword})
|
||||
phpsessid = (str(loginrq.cookies.get_dict()["PHPSESSID"]))
|
||||
regex = r'(<div id="token" hidden>)(\S+)(<\/div>)'
|
||||
try:
|
||||
token = re.findall(regex, loginrq.text, re.MULTILINE)[0][1]
|
||||
except IndexError:
|
||||
log.error(f"An authentication token wasn't returned from the Pi-hole server at {apiurl} - your password is likely incorrect!")
|
||||
exit()
|
||||
log.debug("phpsessid: " + phpsessid + " Token: "+ token)
|
||||
return {'phpsessid': phpsessid, "csrftoken": token}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user