diff options
| author | Vidhin Mehta (OpenERP) <vme@tinyerp.com> | 2012-10-15 17:03:32 +0530 |
|---|---|---|
| committer | Vidhin Mehta (OpenERP) <vme@tinyerp.com> | 2012-10-15 17:03:32 +0530 |
| commit | 287b9d09eb740f6adfafdbbc65265f2aecf515ba (patch) | |
| tree | d0d686830d71c964f03bc69f85c3ef26dec6f006 /addons/auth_reset_password/controllers | |
| parent | 3eb5cfb61b6bbb84043f4fa6b3fdefb0fbb320c7 (diff) | |
| parent | 7f23ad5de563eacfcae958d0011637800b097d4a (diff) | |
[MERGE]trunk.
bzr revid: vme@tinyerp.com-20121015113332-i8g3d8na27j08h3l
Diffstat (limited to 'addons/auth_reset_password/controllers')
| -rw-r--r-- | addons/auth_reset_password/controllers/__init__.py | 24 | ||||
| -rw-r--r-- | addons/auth_reset_password/controllers/main.py | 52 |
2 files changed, 76 insertions, 0 deletions
diff --git a/addons/auth_reset_password/controllers/__init__.py b/addons/auth_reset_password/controllers/__init__.py new file mode 100644 index 00000000000..f40f0ee976e --- /dev/null +++ b/addons/auth_reset_password/controllers/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2012-today OpenERP SA (<http://www.openerp.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/> +# +############################################################################## + +import main + +# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_reset_password/controllers/main.py b/addons/auth_reset_password/controllers/main.py new file mode 100644 index 00000000000..639945cfc09 --- /dev/null +++ b/addons/auth_reset_password/controllers/main.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2012-today OpenERP SA (<http://www.openerp.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/> +# +############################################################################## +import logging + +import werkzeug + +import openerp +from openerp import SUPERUSER_ID +from openerp.modules.registry import RegistryManager + +_logger = logging.getLogger(__name__) + +class Controller(openerp.addons.web.http.Controller): + _cp_path = '/auth_reset_password' + + @openerp.addons.web.http.httprequest + def reset_password(self, req, dbname, login): + """ retrieve user, and perform reset password """ + url = '/' + registry = RegistryManager.get(dbname) + with registry.cursor() as cr: + try: + res_users = registry.get('res.users') + res_users.reset_password(cr, SUPERUSER_ID, login) + cr.commit() + message = 'An email has been sent with credentials to reset your password' + except Exception as e: + # signup error + _logger.exception('error when resetting password') + message = e.message + url = "/#action=login&error_message=%s" % werkzeug.urls.url_quote(message) + return werkzeug.utils.redirect(url) + +# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4: |
