diff --git a/addons/auth_signup/__openerp__.py b/addons/auth_signup/__openerp__.py index 08740962c59..7318ecfd8ef 100644 --- a/addons/auth_signup/__openerp__.py +++ b/addons/auth_signup/__openerp__.py @@ -34,11 +34,13 @@ Allow users to sign up and reset their password 'depends': [ 'base_setup', 'email_template', + 'web', ], 'data': [ 'auth_signup_data.xml', 'res_config.xml', 'res_users_view.xml', + 'views/auth_signup_login.xml', ], 'js': ['static/src/js/auth_signup.js'], 'qweb': ['static/src/xml/auth_signup.xml'], diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index a778cbcf061..7948e737327 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -22,16 +22,27 @@ import logging import openerp from openerp import http -from openerp.http import request +from openerp.http import request, LazyResponse from openerp.modules.registry import RegistryManager from ..res_users import SignupError _logger = logging.getLogger(__name__) -class Controller(http.Controller): +class Home(openerp.addons.web.controllers.main.Home): - @http.route('/auth_signup/get_config', type='json', auth="none") - def get_config(self, dbname): + @http.route('/web/login', type='http', auth="none") + def web_login(self, *args, **kw): + response = super(Home, self).web_login(*args, **kw) + if isinstance(response, LazyResponse): + config = self.get_auth_signup_config(request.session.db) + response.params['values'].update(config) + if request.params.get('signup', None) and config['signup']: + response.params['template'] = 'auth_signup.signup' + if request.params.get('reset', None) and config['signup']: + response.params['template'] = 'auth_signup.reset' + return response + + def get_auth_signup_config(self, dbname): """ retrieve the module config (which features are enabled) for the login page """ registry = RegistryManager.get(dbname) with registry.cursor() as cr: @@ -42,6 +53,8 @@ class Controller(http.Controller): } return config +class Controller(http.Controller): + @http.route('/auth_signup/retrieve', type='json', auth="none") def retrieve(self, dbname, token): """ retrieve the user info (name, login or email) corresponding to a signup token """ diff --git a/addons/auth_signup/res_users.py b/addons/auth_signup/res_users.py index 669ea3a56a1..0379cd2c0c1 100644 --- a/addons/auth_signup/res_users.py +++ b/addons/auth_signup/res_users.py @@ -66,19 +66,19 @@ class res_partner(osv.Model): self.signup_prepare(cr, uid, [partner.id], context=context) partner.refresh() - # the parameters to encode for the query and fragment part of url - query = {'db': cr.dbname} + # the parameters to encode for the query + query = dict(db=cr.dbname) signup_type = context.get('signup_force_type_in_url', partner.signup_type or '') - fragment = {'action': action, 'type': signup_type} + query[signup_type] = 1 if partner.signup_token and signup_type: - fragment['token'] = partner.signup_token + query['token'] = partner.signup_token elif partner.user_ids: - fragment['db'] = cr.dbname - fragment['login'] = partner.user_ids[0].login + query['login'] = partner.user_ids[0].login else: continue # no signup token, no user, thus no signup url! + fragment = dict() if view_type: fragment['view_type'] = view_type if menu_id: @@ -88,7 +88,7 @@ class res_partner(osv.Model): if res_id: fragment['id'] = res_id - res[partner.id] = urljoin(base_url, "?%s#%s" % (urlencode(query), urlencode(fragment))) + res[partner.id] = urljoin(base_url, "/web/login?%s#%s" % (urlencode(query), urlencode(fragment))) return res diff --git a/addons/auth_signup/static/src/js/auth_signup.js b/addons/auth_signup/static/src/js/auth_signup.js index d10f96316e2..b5e6f91b139 100644 --- a/addons/auth_signup/static/src/js/auth_signup.js +++ b/addons/auth_signup/static/src/js/auth_signup.js @@ -2,7 +2,8 @@ openerp.auth_signup = function(instance) { instance.auth_signup = instance.auth_signup || {}; var _t = instance.web._t; - /* TODO: make this a server side controller + return; + instance.web.Login.include({ start: function() { var self = this; @@ -184,5 +185,4 @@ openerp.auth_signup = function(instance) { }); }, }); - */ }; diff --git a/addons/auth_signup/views/auth_signup_login.xml b/addons/auth_signup/views/auth_signup_login.xml new file mode 100644 index 00000000000..38aef1e2099 --- /dev/null +++ b/addons/auth_signup/views/auth_signup_login.xml @@ -0,0 +1,72 @@ + + + + + + + + + +