diff options
| author | Mayur Maheshwari (OpenERP) <mma@tinyerp.com> | 2012-10-10 10:49:17 +0530 |
|---|---|---|
| committer | Mayur Maheshwari (OpenERP) <mma@tinyerp.com> | 2012-10-10 10:49:17 +0530 |
| commit | 79a84ffc5d2afaec71225b0e70dcccb79ecc8239 (patch) | |
| tree | 0e6b2ae62ba8d02d7c1d987b438a02ed7baea07f /addons/auth_reset_password/controllers | |
| parent | 9487c2d9ba9381e04c677d861864e29895f48e8e (diff) | |
| parent | 49b102b54a860e655156fced1940ae6b913a7458 (diff) | |
[MERGE]: Merge with lp:openobject-addons
bzr revid: mma@tinyerp.com-20121010051917-0ep6z3xy0ff92kzo
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..5185a65c3ce --- /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/> +# +############################################################################## + +from openerp import SUPERUSER_ID +from openerp.modules.registry import RegistryManager +import openerp.addons.web.common.http as openerpweb + +import werkzeug + +import logging +_logger = logging.getLogger(__name__) + +class Controller(openerpweb.Controller): + _cp_path = '/auth_reset_password' + + @openerpweb.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: |
