fix: case where background task had no IP

(cherry picked from commit 67374fdb94937231a7b3f2d4b9fcf5e6323e4e56)
This commit is contained in:
RJPvT 2020-04-28 21:21:17 +02:00 committed by mergify-bot
parent d0f6004d56
commit ebe298113c

View file

@ -30,7 +30,7 @@ def two_factor_is_enabled(user=None):
if bypass_two_factor_auth and user:
user_doc = frappe.get_doc("User", user)
restrict_ip_list = user_doc.get_restricted_ip_list() #can be None or one or more than one ip address
if restrict_ip_list:
if restrict_ip_list and frappe.local.request_ip:
for ip in restrict_ip_list:
if frappe.local.request_ip.startswith(ip):
enabled = False