Mercurial > kallithea
diff rhodecode/controllers/api/api.py @ 3126:703070153bc1 beta
added API method for checking IP
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 31 Dec 2012 01:51:30 +0100 |
parents | 9b92cf5a0cca |
children | 3563c47e52fd |
line wrap: on
line diff
--- a/rhodecode/controllers/api/api.py Sun Dec 30 23:06:03 2012 +0100 +++ b/rhodecode/controllers/api/api.py Mon Dec 31 01:51:30 2012 +0100 @@ -38,7 +38,7 @@ from rhodecode.model.user import UserModel from rhodecode.model.users_group import UsersGroupModel from rhodecode.model.permission import PermissionModel -from rhodecode.model.db import Repository, RhodeCodeSetting +from rhodecode.model.db import Repository, RhodeCodeSetting, UserIpMap log = logging.getLogger(__name__) @@ -140,9 +140,6 @@ errors that happens """ - def _get_ip_addr(self, environ): - from rhodecode.lib.base import _get_ip_addr - return _get_ip_addr(environ) @HasPermissionAllDecorator('hg.admin') def pull(self, apiuser, repoid): @@ -215,6 +212,22 @@ ) @HasPermissionAllDecorator('hg.admin') + def show_ip(self, apiuser, userid): + """ + Shows IP address as seen from RhodeCode server, together with all + defined IP addresses for given user + + :param apiuser: + :param userid: + """ + user = get_user_or_error(userid) + ips = UserIpMap.query().filter(UserIpMap.user == user).all() + return dict( + ip_addr_server=self.ip_addr, + user_ips=ips + ) + + @HasPermissionAllDecorator('hg.admin') def get_user(self, apiuser, userid): """" Get a user by username