From 580cbe6e1abfd611df3aa58349643a0aec0035e8 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Tue, 9 Dec 2014 14:00:03 +0100 Subject: [PATCH] [ADD] 'auth_generate_password' module to generate randomly user's password --- auth_generate_password/__init__.py | 23 ++++++ auth_generate_password/__openerp__.py | 70 +++++++++++++++++ .../data/email_template.xml | 45 +++++++++++ .../data/ir_config_parameter.yml | 29 +++++++ auth_generate_password/demo/res_groups.yml | 25 ++++++ auth_generate_password/demo/res_users.yml | 26 +++++++ auth_generate_password/i18n/fr.po | 72 ++++++++++++++++++ auth_generate_password/model/__init__.py | 23 ++++++ auth_generate_password/model/res_users.py | 61 +++++++++++++++ .../static/src/img/icon.png | Bin 0 -> 6860 bytes auth_generate_password/tests/__init__.py | 27 +++++++ auth_generate_password/tests/tests.py | 53 +++++++++++++ auth_generate_password/view/view.xml | 48 ++++++++++++ 13 files changed, 502 insertions(+) create mode 100644 auth_generate_password/__init__.py create mode 100644 auth_generate_password/__openerp__.py create mode 100644 auth_generate_password/data/email_template.xml create mode 100644 auth_generate_password/data/ir_config_parameter.yml create mode 100644 auth_generate_password/demo/res_groups.yml create mode 100644 auth_generate_password/demo/res_users.yml create mode 100644 auth_generate_password/i18n/fr.po create mode 100644 auth_generate_password/model/__init__.py create mode 100644 auth_generate_password/model/res_users.py create mode 100644 auth_generate_password/static/src/img/icon.png create mode 100644 auth_generate_password/tests/__init__.py create mode 100644 auth_generate_password/tests/tests.py create mode 100644 auth_generate_password/view/view.xml diff --git a/auth_generate_password/__init__.py b/auth_generate_password/__init__.py new file mode 100644 index 000000000..782a258d8 --- /dev/null +++ b/auth_generate_password/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Authentification - Generate Password module for Odoo +# Copyright (C) 2013-2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# 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 . +# +############################################################################## + +from . import model diff --git a/auth_generate_password/__openerp__.py b/auth_generate_password/__openerp__.py new file mode 100644 index 000000000..03241dca0 --- /dev/null +++ b/auth_generate_password/__openerp__.py @@ -0,0 +1,70 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Authentification - Generate Password module for Odoo +# Copyright (C) 2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# 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 . +# +############################################################################## + +{ + 'name': 'Password Secure', + 'version': '2.0', + 'category': 'GRAP - Custom', + 'description': """ +Password Secure +=============== + +Functionnality: +--------------- + * Forbid users to change them password; + * Only members of base.group_system can change password; OK. + * Add a button to the res_users form: + * to change the password (randomly generated); + * send an email to each users; + +Settings: +--------- + * Once the module installed, you have to set two settings: + * password size: the size of the password generated (6 by default); + * password chars: the list of allowed chars (by default ASCII letters + and digits); You can: + * set a list of chars like 'abcdef'; + * use string function like string.ascii_letters; + * Be sure that an Outgoing Email Server is correctly configured; + +Copyright, Author and Licence : +------------------------------- + * Copyright : 2014, Groupement Régional Alimentaire de Proximité; + * Author : Sylvain LE GAL (https://twitter.com/legalsylvain); + * Licence : AGPL-3 (http://www.gnu.org/licenses/) + """, + 'author': 'GRAP', + 'website': 'http://www.grap.coop', + 'license': 'AGPL-3', + 'depends': [ + 'email_template', + ], + 'data': [ + 'data/ir_config_parameter.yml', + 'data/email_template.xml', + 'view/view.xml', + ], + 'demo': [ + 'demo/res_groups.yml', + 'demo/res_users.yml', + ], +} diff --git a/auth_generate_password/data/email_template.xml b/auth_generate_password/data/email_template.xml new file mode 100644 index 000000000..b22920aa9 --- /dev/null +++ b/auth_generate_password/data/email_template.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Generate Password + + ]]> + ${object.email|safe} + OpenERP - Password Changed + +
  • Login : ${object.login}
  • +
  • New Password : ${object.password}
  • + +Please, +
      +
    • remember this password and delete this email;
    • +
    • Communicate the password to your team, if you are many people to use the same credentials;
    • +
    ]]> +
    +
    + +
    +
    diff --git a/auth_generate_password/data/ir_config_parameter.yml b/auth_generate_password/data/ir_config_parameter.yml new file mode 100644 index 000000000..6282a0ff7 --- /dev/null +++ b/auth_generate_password/data/ir_config_parameter.yml @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Authentification - Generate Password module for Odoo +# Copyright (C) 2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# 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 . +# +############################################################################## + +- !record {model: ir.config_parameter, id: password_size}: + key: auth_generate_password.password_size + value: 6 + +- !record {model: ir.config_parameter, id: password_chars}: + key: auth_generate_password.password_chars + value: string.ascii_letters + string.digits diff --git a/auth_generate_password/demo/res_groups.yml b/auth_generate_password/demo/res_groups.yml new file mode 100644 index 000000000..e52835925 --- /dev/null +++ b/auth_generate_password/demo/res_groups.yml @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Authentification - Generate Password module for Odoo +# Copyright (C) 2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# 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 . +# +############################################################################## + +- !record {model: res.groups, id: base.group_no_one}: + users: + - base.user_root diff --git a/auth_generate_password/demo/res_users.yml b/auth_generate_password/demo/res_users.yml new file mode 100644 index 000000000..00b401abe --- /dev/null +++ b/auth_generate_password/demo/res_users.yml @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Authentification - Generate Password module for Odoo +# Copyright (C) 2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# 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 . +# +############################################################################## + +- !record {model: res.users, id: extra_user}: + name: Extra User + login: extra + email: extra@example.com diff --git a/auth_generate_password/i18n/fr.po b/auth_generate_password/i18n/fr.po new file mode 100644 index 000000000..2ffaae6cf --- /dev/null +++ b/auth_generate_password/i18n/fr.po @@ -0,0 +1,72 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * auth_generate_password +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-12-09 12:53+0000\n" +"PO-Revision-Date: 2014-12-09 12:53+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: auth_generate_password +#: model:email.template,body_html:auth_generate_password.generate_password_template +msgid "\n" +"Your OpenERP credentials has been changed:\n" +"
      \n" +"
    • Login : ${object.login}
    • \n" +"
    • New Password : ${object.password}
    • \n" +"
    \n" +"Please,\n" +"
      \n" +"
    • remember this password and delete this email;
    • \n" +"
    • Communicate the password to your team, if you are many people to use the same credentials;
    • \n" +"
    \n" +" " +msgstr "\n" +"Vos identifiants OpenERP ont changés :\n" +"
      \n" +"
    • Login : ${object.login}
    • \n" +"
    • Nouveau Mot de passe : ${object.password}
    • \n" +"
    \n" +"Merci de,\n" +"
      \n" +"
    • vous souvenir de ce mot de passe et de supprimer cet email ;
    • \n" +"
    • de communiquer ce mot de passe Ă  votre Ă©quipe, si plusieurs personnes utilisent les mĂȘme identifiants;
    • \n" +"
    \n" +" " + +#. module: auth_generate_password +#: code:addons/auth_generate_password/model/res_users.py:48 +#, python-format +msgid "Cannot send email: user has no email address." +msgstr "Impossible d'envoyer un email : l'utilisateur n'a pas d'adresse." + +#. module: auth_generate_password +#: view:res.users:0 +msgid "Generate Password and Send Mail" +msgstr "Générer un mot de passe et envoyer un email" + +#. module: auth_generate_password +#: model:email.template,subject:auth_generate_password.generate_password_template +msgid "OpenERP - Password Changed" +msgstr "OpenERP - Mot de passe changé" + +#. module: auth_generate_password +#: code:_description:0 +#: model:ir.model,name:auth_generate_password.model_res_users +#, python-format +msgid "Users" +msgstr "Utilisateurs" + +#. module: auth_generate_password +#: view:res.users:0 +msgid "base.group_system" +msgstr "base.group_system" + diff --git a/auth_generate_password/model/__init__.py b/auth_generate_password/model/__init__.py new file mode 100644 index 000000000..e5a505c75 --- /dev/null +++ b/auth_generate_password/model/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Authentification - Generate Password module for Odoo +# Copyright (C) 2013-2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# 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 . +# +############################################################################## + +from . import res_users diff --git a/auth_generate_password/model/res_users.py b/auth_generate_password/model/res_users.py new file mode 100644 index 000000000..47d78d4d0 --- /dev/null +++ b/auth_generate_password/model/res_users.py @@ -0,0 +1,61 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Authentification - Generate Password module for Odoo +# Copyright (C) 2013-2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# 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 . +# +############################################################################## + +# This line is noqa flaged, to allow users to use string functions written +# in ir_config_parameter +import string # flake8: noqa +import random + +from openerp.osv.orm import Model +from openerp.osv.osv import except_osv +from openerp.tools.translate import _ + + +class res_users(Model): + _inherit = 'res.users' + + def generate_password(self, cr, uid, ids, context=None): + mm_obj = self.pool['mail.mail'] + icp_obj = self.pool['ir.config_parameter'] + imd_obj = self.pool['ir.model.data'] + et_obj = self.pool['email.template'] + password_size = eval(icp_obj.get_param( + cr, uid, 'auth_generate_password.password_size')) + password_chars = eval(icp_obj.get_param( + cr, uid, 'auth_generate_password.password_chars')) + for ru in self.browse(cr, uid, ids, context=context): + if not ru.email: + raise osv.except_osv( + _("Cannot send email: user has no email address."), + user.name) + # Generate Password + password = "".join([random.choice( + password_chars) for n in xrange(password_size)]) + self._set_new_password( + cr, uid, ru.id, None, password, None, context=None) + # Send Mail + et = imd_obj.get_object( + cr, uid, 'auth_generate_password', + 'generate_password_template') + mail_id = et_obj.send_mail( + cr, uid, et.id, ru.id, True, context=context) + return {} diff --git a/auth_generate_password/static/src/img/icon.png b/auth_generate_password/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..2cb11b276e88dc64a26a698e38d44466bd027d95 GIT binary patch literal 6860 zcmV;-8Z+gIP)p6khvk3#jFVg z0tCVk6BgTmH@sW6ELn>swbW|$e$KgnC=QF&t=_a+@AK%NKIc@Gx_?!t>Z|YjO6a<- zGr?JlG|~;2U}TvPz*&wm(hW$4mey86p)*>;xJ*Ryu*TISZxrns;Ox7$6^%^GrsMF8!m zPO*K*4qkfsWnTHiA2`*~In-6AMR{2%=dD`B+Vjq%W?D6clL|2!jU(NxAz?@b5Q#+C zwtYKWo_?BFUVDw!*0!OlYDjSBoDWeRT0FE{^@bq)f z@#0IrXZPN{Xqq+@)eH+xr;}MTXRv0~YA(O*Qi=e%h| zu@FMwa=BQ!Vl`j?yIZNLu11oiF}rHWm;g?7bnu_w{{cVy#V;~Z+?XIQFPB?3Zsh7K zucWB35LuQ-x=Bfs5dj=O-pIY1H}mv!&vCYGE*cC5E?B#Uo4#}dOPAD-ITLi+0yuQ| zFyH&ZL;U827YGL9+v&$Ml~X2j`)#*#$-2+ua5zS~ISG@N01h2K%!3d8kmp}~k-omZ zOtx!G;?B+Eh7DJ9_2?-BH1j+1ul%GB^b*JG0bvfnmv8E|AkMt zITZo)`h5KOzy6Dde*6;xfxu9-Yt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ax;l8=NMD~vh;oF*9Qpf_-Ylb+W(>3JRBFdS1O2?KfAi>S(9k29-o%rEg0 zVblr$`d15@9wrp&q|>*P;~l@H!@C_-3!>|42IdM. +# +############################################################################## + +from . import tests + +fast_suite = [ + tests, +] diff --git a/auth_generate_password/tests/tests.py b/auth_generate_password/tests/tests.py new file mode 100644 index 000000000..6a3b67934 --- /dev/null +++ b/auth_generate_password/tests/tests.py @@ -0,0 +1,53 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Authentification - Generate Password module for Odoo +# Copyright (C) 2013-2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# 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 . +# +############################################################################## + +from openerp.tests.common import TransactionCase + + +class TestAuthGeneratePassword(TransactionCase): + + def setUp(self): + super(TestAuthGeneratePassword, self).setUp() + cr, uid = self.cr, self.uid + self.imd_obj = self.registry('ir.model.data') + self.ru_obj = self.registry('res.users') + self.mm_obj = self.registry('mail.mail') + self.demo_ru_id = self.imd_obj.get_object_reference( + cr, uid, 'base', + 'user_demo')[1] + self.extra_ru_id = self.imd_obj.get_object_reference( + cr, uid, 'auth_generate_password', + 'extra_user')[1] + + # Test Section + def test_01_generate_password(self): + """[Functional Test] Test if generate password generate mails""" + cr, uid = self.cr, self.uid + ru_ids = [self.demo_ru_id, self.extra_ru_id] + mm_qty_before = len(self.mm_obj.search(cr, uid, [])) + self.ru_obj.generate_password(cr, uid, ru_ids) + mm_qty_after = len(self.mm_obj.search(cr, uid, [])) + + self.assertEquals( + mm_qty_before + len(ru_ids), mm_qty_after, + "Generate password for %d user(s) must send %d email(s) !" % ( + len(ru_ids), len(ru_ids))) diff --git a/auth_generate_password/view/view.xml b/auth_generate_password/view/view.xml new file mode 100644 index 000000000..e1dfe3b24 --- /dev/null +++ b/auth_generate_password/view/view.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + res.users + + + + + + + + res.users + + + +