diff --git a/webnotes/__init__.py b/webnotes/__init__.py index 28a4a78ba8..0a8e92b031 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -179,7 +179,7 @@ def get_env_vars(env_var): import os return os.environ.get(env_var,'None') -remote_ip = get_env_vars('REMOTE_ADDR') #Required for login from python shell +remote_ip = get_env_vars('HTTP_X_FORWARDED_FOR') or get_env_vars('REMOTE_ADDR') #Required for login from python shell logger = None def get_db_password(db_name): diff --git a/webnotes/auth.py b/webnotes/auth.py index 9ffcb1398e..a449c4e275 100644 --- a/webnotes/auth.py +++ b/webnotes/auth.py @@ -20,9 +20,9 @@ class HTTPRequest: # language self.set_lang(webnotes.get_env_vars('HTTP_ACCEPT_LANGUAGE')) - - webnotes.remote_ip = webnotes.get_env_vars('REMOTE_ADDR') + webnotes.remote_ip = webnotes.get_env_vars('HTTP_X_FORWARDED_FOR') or webnotes.get_env_vars('REMOTE_ADDR') + # load cookies webnotes.cookie_manager = CookieManager() @@ -115,7 +115,7 @@ class LoginManager: full_name = " ".join(filter(None, [info.first_name, info.last_name])) webnotes.response["full_name"] = full_name webnotes.add_cookies["full_name"] = full_name - + def post_login(self): self.run_trigger() self.validate_ip_address() @@ -271,4 +271,4 @@ def _update_password(user, password): @webnotes.whitelist() def get_logged_user(): - return webnotes.session.user \ No newline at end of file + return webnotes.session.user