Dave Lasley
9 years ago
committed by
Ted Salmon
10 changed files with 12954 additions and 0 deletions
-
32res_users_case_insensitive/README.rst
-
3res_users_case_insensitive/__init__.py
-
32res_users_case_insensitive/__openerp__.py
-
3res_users_case_insensitive/models/__init__.py
-
52res_users_case_insensitive/models/fields.py
-
34res_users_case_insensitive/models/res_users.py
-
BINres_users_case_insensitive/static/description/icon.png
-
12745res_users_case_insensitive/static/description/icon.svg
-
2res_users_case_insensitive/tests/__init__.py
-
51res_users_case_insensitive/tests/test_res_users.py
@ -0,0 +1,32 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
========================== |
|||
Case Insensitive Usernames |
|||
========================== |
|||
|
|||
This module extends the functionality of res.users to make logins case |
|||
insensitive. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Images |
|||
------ |
|||
|
|||
* LasLabs: `Icon <https://repo.laslabs.com/projects/TEM/repos/odoo-module_template/browse/module_name/static/description/icon.svg?raw>`_. |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Firstname Lastname <email.address@laslabs.com> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://laslabs.com/logo.png |
|||
:alt: LasLabs Inc. |
|||
:target: https://laslabs.com |
|||
|
|||
This module is maintained by LasLabs Inc. |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import models |
|||
from . import tests |
@ -0,0 +1,32 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Author: Dave Lasley <dave@laslabs.com> |
|||
# Copyright: 2016-TODAY LasLabs, Inc. [https://laslabs.com] |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
{ |
|||
"name": "Case Insensitive Logins", |
|||
"summary": "Makes the login field of res.users case insensitive.", |
|||
"version": "9.0.1.0.0", |
|||
"category": "Base", |
|||
"website": "https://laslabs.com/", |
|||
"author": "LasLabs", |
|||
"license": "AGPL-3", |
|||
"application": False, |
|||
"installable": True, |
|||
} |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import fields |
|||
from . import res_users |
@ -0,0 +1,52 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Author: Dave Lasley <dave@laslabs.com> |
|||
# Copyright: 2015 LasLabs, Inc. |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
|
|||
from openerp import fields |
|||
import base64 |
|||
from Crypto.Cipher import AES |
|||
from Crypto import Random |
|||
|
|||
|
|||
class CharLower(fields.Char): |
|||
""" |
|||
Identical to fields.Char, except lower cased |
|||
|
|||
:param int size: the maximum size of values stored for that field |
|||
:param translate: whether the value of this field can be translated |
|||
""" |
|||
|
|||
def convert_to_cache(self, value, record, validate=True): |
|||
""" |
|||
convert ``value`` to the cache level in ``env``; ``value`` may come |
|||
from an assignment, or have the format of methods |
|||
:meth:`BaseModel.read` or :meth:`BaseModel.write` |
|||
|
|||
:param record: the target record for the assignment, |
|||
or an empty recordset |
|||
|
|||
:param bool validate: when True, field-specific validation of |
|||
``value`` will be performed |
|||
""" |
|||
res = super(CharLower, self).convert_to_cache(value, record, validate) |
|||
if not res: |
|||
return res |
|||
return res.lower() |
@ -0,0 +1,34 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Author: Dave Lasley <dave@laslabs.com> |
|||
# Copyright: 2016-TODAY LasLabs, Inc. [https://laslabs.com] |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from openerp import models, api |
|||
from openerp.exceptions import ValidationError |
|||
|
|||
from openerp.addons.res_users_case_insensitive.models.fields import CharLower |
|||
|
|||
class ResUsers(models.Model): |
|||
_inherit = 'res.users' |
|||
login = CharLower( |
|||
'Login', |
|||
size=64, |
|||
required=True, |
|||
help='Used to log into the system. Case insensitive.', |
|||
) |
After Width: 600 | Height: 518 | Size: 10 KiB |
12745
res_users_case_insensitive/static/description/icon.svg
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import test_something |
@ -0,0 +1,51 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Author: Dave Lasley <dave@laslabs.com> |
|||
# Copyright: 2016-TODAY LasLabs, Inc. [https://laslabs.com] |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from openerp.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestResUsers(TransactionCase): |
|||
|
|||
def setUp(self, *args, **kwargs): |
|||
result = super(SomethingCase, self).setUp(*args, **kwargs) |
|||
self.login = 'TeSt@ExAmPlE.CoM' |
|||
self.partner_vals = { |
|||
'name': 'Partner', |
|||
'is_company': False, |
|||
'email': self.login, |
|||
} |
|||
self.vals = { |
|||
'name': 'User', |
|||
'login': self.login, |
|||
'password': 'password', |
|||
} |
|||
self.model_obj = self.env['res.users'] |
|||
|
|||
def _new_record(self, ): |
|||
partner_id = self.env['res.partner'].create(self.partner_vals) |
|||
return self.model_obj.create(self.vals) |
|||
|
|||
def test_login_is_lowercased_on_save(self, ): |
|||
rec_id = self._new_record() |
|||
self.assertEqual( |
|||
self.login.lower(), rec_id.login, |
|||
'Login was not lowercased when saved to cache', |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue