Add ir.message and use custom exceptions
issue3672
This commit is contained in:
1 parent
feb1fcb6f2
commit
984f2420ea
3 files changed
+17
-9
No files matched your search
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data group="1">
|
||||
<record model="ir.message" id="msg_ldap_user_change_password">
|
||||
<field name="text">You cannot change the password of LDAP user "%(user)s".</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -6,6 +6,8 @@ import urllib.parse
|
||||
import ldap3
|
||||
from ldap3.core.exceptions import LDAPException
|
||||
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.config import config, parse_uri
|
||||
@@ -51,14 +53,6 @@ def ldap_server():
|
||||
class User(metaclass=PoolMeta):
|
||||
__name__ = 'res.user'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(User, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'set_passwd_ldap_user': (
|
||||
'You can not set the password of ldap user "%s".'),
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def ldap_search_user(login, server, attrs=None):
|
||||
'''
|
||||
@@ -109,7 +103,9 @@ class User(metaclass=PoolMeta):
|
||||
except LDAPException:
|
||||
logger.error('LDAPError when checking password', exc_info=True)
|
||||
if find:
|
||||
cls.raise_user_error('set_passwd_ldap_user', (login,))
|
||||
raise AccessError(
|
||||
gettext('ldap_authentication.msg_ldap_user_change_password',
|
||||
user=login))
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
|
||||
@@ -3,3 +3,5 @@ version=5.1.0
|
||||
depends:
|
||||
ir
|
||||
res
|
||||
xml:
|
||||
message.xml
|
||||
Reference in new issue
Block a user