Procházet zdrojové kódy

added frappe.local.request_ip

version-14
Rushabh Mehta před 11 roky
rodič
revize
eb41de8f76
2 změnil soubory, kde provedl 4 přidání a 1 odebrání
  1. +1
    -0
      frappe/__init__.py
  2. +3
    -1
      frappe/auth.py

+ 1
- 0
frappe/__init__.py Zobrazit soubor

@@ -94,6 +94,7 @@ def init(site, sites_path=None):
local.site_path = os.path.join(sites_path, site)

local.request_method = request.method if request else None
local.request_ip = None
local.response = _dict({"docs":[]})

local.conf = _dict(get_site_config())


+ 3
- 1
frappe/auth.py Zobrazit soubor

@@ -20,6 +20,8 @@ class HTTPRequest:
if self.domain and self.domain.startswith('www.'):
self.domain = self.domain[4:]

frappe.local.request_ip = frappe.get_request_header('REMOTE_ADDR') \
or frappe.get_request_header('X-Forwarded-For') or '127.0.0.1'
# language
self.set_lang(frappe.get_request_header('HTTP_ACCEPT_LANGUAGE'))

@@ -157,7 +159,7 @@ class LoginManager:
ip_list = [i.strip() for i in ip_list]

for ip in ip_list:
if frappe.get_request_header('REMOTE_ADDR', '').startswith(ip) or frappe.get_request_header('X-Forwarded-For', '').startswith(ip):
if frappe.local.request_ip.startswith(ip):
return

frappe.throw(_("Not allowed from this IP Address"), frappe.AuthenticationError)


Načítá se…
Zrušit
Uložit