Skip to content

Commit aef3521

Browse files
[FIX] auth_oauth_ip: Do not break inheritance in _auth_oauth_validate to
call auth_oauth_check_client_id method
1 parent 0f05702 commit aef3521

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

auth_oauth_ip/models.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class res_users(models.Model):
2222

2323
_inherit = 'res.users'
2424

25-
def _auth_oauth_rpc(self, endpoint, access_token, local_host=None, local_port=None):
25+
def _auth_oauth_rpc(self, endpoint, access_token):
26+
local_host = self.env.context.get('local_host')
27+
local_port = self.env.context.get('local_port')
2628
params = werkzeug.url_encode({'access_token': access_token})
2729
host = None
2830
try:
@@ -39,22 +41,13 @@ def _auth_oauth_rpc(self, endpoint, access_token, local_host=None, local_port=No
3941
else:
4042
url = endpoint + '?' + params
4143
req = urllib.request.Request(url, headers={'host': host})
42-
print(('url', url))
4344

4445
with urllib.request.urlopen(req) as response:
4546
html = response.read()
4647
return json.loads(html.decode("utf-8"))
4748

4849
@api.model
4950
def _auth_oauth_validate(self, provider, access_token):
50-
""" return the validation data corresponding to the access token """
5151
p = self.env['auth.oauth.provider'].browse(provider)
52-
validation = self._auth_oauth_rpc(
53-
p.validation_endpoint, access_token, local_host=p.local_host, local_port=p.local_port)
54-
if validation.get("error"):
55-
raise Exception(validation['error'])
56-
if p.data_endpoint:
57-
data = self._auth_oauth_rpc(
58-
p.data_endpoint, access_token, local_host=p.local_host, local_port=p.local_port)
59-
validation.update(data)
60-
return validation
52+
self = self.with_context(local_host=p.local_host, local_port=p.local_port)
53+
return super(res_users, self)._auth_oauth_validate(provider, access_token)

0 commit comments

Comments
 (0)