Browse Source

Merge pull request #1466 from etobella/11.0-fix-remote

[FIX] base_remote: Do not raise Error on login failure
pull/1600/head
Jordi Ballester Alomar 6 years ago
committed by GitHub
parent
commit
0b718c2dcc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      base_remote/__manifest__.py
  2. 4
      base_remote/models/base.py
  3. 8
      base_remote/models/res_users.py
  4. 3
      base_remote/tests/test_remote.py

2
base_remote/__manifest__.py

@ -3,7 +3,7 @@
{
'name': "Remote Base",
'version': '11.0.1.0.3',
'version': '11.0.1.0.4',
'category': 'Generic Modules/Base',
'author': "Creu Blanca, Odoo Community Association (OCA)",
'website': 'http://github.com/OCA/server-tools',

4
base_remote/models/base.py

@ -13,5 +13,7 @@ class Base(models.AbstractModel):
try:
remote_addr = current_thread().environ["REMOTE_ADDR"]
except KeyError:
remote_addr = False
return self.env['res.remote']
except AttributeError:
return self.env['res.remote']
return self.env['res.remote']._get_remote(remote_addr)

8
base_remote/models/res_users.py

@ -3,7 +3,6 @@
from threading import current_thread
from odoo import api, models, SUPERUSER_ID
from odoo.exceptions import AccessDenied
from odoo.service import wsgi_server
@ -30,12 +29,9 @@ class ResUsers(models.Model):
with cls.pool.cursor() as cr:
env = api.Environment(cr, SUPERUSER_ID, {})
remote = env["res.users"].remote
if remote:
remote.ensure_one()
result = method()
if not result:
# Force exception to record auth failure
raise AccessDenied()
return result
return method()
# Override all auth-related core methods
@classmethod

3
base_remote/tests/test_remote.py

@ -1,8 +1,6 @@
# Copyright 2018 Creu Blanca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from xmlrpc.client import Fault
from mock import patch
from werkzeug.utils import redirect
@ -56,7 +54,6 @@ class TestRemote(HttpCase):
"""Test Login Failure"""
data1 = self.data_demo
data1['password'] = 'Failure!'
with self.assertRaises(Fault):
self.assertFalse(self.xmlrpc_common.authenticate(
self.env.cr.dbname, data1["login"], data1["password"], {}))
with self.cursor() as cr:

Loading…
Cancel
Save