Browse Source

[FIX] base_remote: Do not raise Error on login failure

12.0-mig-module_prototyper_last
Enric Tobella 6 years ago
committed by Jaime Arroyo
parent
commit
1e5539c9ad
  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", 'name': "Remote Base",
'version': '11.0.1.0.3',
'version': '11.0.1.0.4',
'category': 'Generic Modules/Base', 'category': 'Generic Modules/Base',
'author': "Creu Blanca, Odoo Community Association (OCA)", 'author': "Creu Blanca, Odoo Community Association (OCA)",
'website': 'http://github.com/OCA/server-tools', 'website': 'http://github.com/OCA/server-tools',

4
base_remote/models/base.py

@ -13,5 +13,7 @@ class Base(models.AbstractModel):
try: try:
remote_addr = current_thread().environ["REMOTE_ADDR"] remote_addr = current_thread().environ["REMOTE_ADDR"]
except KeyError: 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) 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 threading import current_thread
from odoo import api, models, SUPERUSER_ID from odoo import api, models, SUPERUSER_ID
from odoo.exceptions import AccessDenied
from odoo.service import wsgi_server from odoo.service import wsgi_server
@ -30,12 +29,9 @@ class ResUsers(models.Model):
with cls.pool.cursor() as cr: with cls.pool.cursor() as cr:
env = api.Environment(cr, SUPERUSER_ID, {}) env = api.Environment(cr, SUPERUSER_ID, {})
remote = env["res.users"].remote remote = env["res.users"].remote
if remote:
remote.ensure_one() 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 # Override all auth-related core methods
@classmethod @classmethod

3
base_remote/tests/test_remote.py

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

Loading…
Cancel
Save