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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
9 additions and
14 deletions
-
base_remote/__manifest__.py
-
base_remote/models/base.py
-
base_remote/models/res_users.py
-
base_remote/tests/test_remote.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', |
|
|
|
@ -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) |
|
@ -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 |
|
|
|
@ -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: |
|
|