diff --git a/addons/auth_signup/__openerp__.py b/addons/auth_signup/__openerp__.py index 60d99534bec..a869c623db0 100644 --- a/addons/auth_signup/__openerp__.py +++ b/addons/auth_signup/__openerp__.py @@ -8,7 +8,6 @@ 'installable': True, 'depends': ['auth_anonymous', 'base_setup'], 'data': [ - 'auth_signup.xml', 'res_config.xml', ], 'js': [ diff --git a/addons/auth_signup/auth_signup.py b/addons/auth_signup/auth_signup.py index 64760bed599..ebc72b3aeac 100644 --- a/addons/auth_signup/auth_signup.py +++ b/addons/auth_signup/auth_signup.py @@ -9,22 +9,17 @@ class res_users(osv.Model): class signup_signup(osv.TransientModel): _name = 'auth.signup' + + # TODO add captcha _columns = { 'name': fields.char('Name', size=64), 'email': fields.char('Email', size=64), 'password': fields.char('Password', size=64), - 'password_confirmation': fields.char('Confirm Password', size=64), - 'state': fields.selection([(x, x) for x in 'draft done missmatch'.split()], required=True), - } - _defaults = { - 'state': 'draft', } def create(self, cr, uid, values, context=None): # NOTE here, invalid values raises exceptions to avoid storing # sensitive data into the database (which then are available to anyone) - if values['password'] != values['password_confirmation']: - raise osv.except_osv('Error', 'Passwords missmatch') new_user = { 'name': values['name'], @@ -40,17 +35,5 @@ class signup_signup(osv.TransientModel): else: self.pool.get('res.users').create(cr, 1, new_user, context=context) - # Dont store the password - values = {'state': 'done'} - return super(signup_signup, self).create(cr, uid, values, context) - - def signup(self, cr, uid, ids, context=None): - return { - 'type': 'ir.actions.client', - 'tag': 'login', - } - - def onchange_pw(self, cr, uid, ids, pw, cpw, context=None): - if pw != cpw: - return {'value': {'state': 'missmatch'}} - return {'value': {'state': 'draft'}} + # Dont store anything + return 0 diff --git a/addons/auth_signup/auth_signup.xml b/addons/auth_signup/auth_signup.xml deleted file mode 100644 index 8940045bbc1..00000000000 --- a/addons/auth_signup/auth_signup.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - auth.signup.form - auth.signup - form - - - - - - - - - - Passwords missmatch - - - - - - - You can now login. - - - - - - - - auth.signup - ir.actions.act_window - auth.signup - form - form - new - - - - diff --git a/addons/auth_signup/static/src/js/auth_signup.js b/addons/auth_signup/static/src/js/auth_signup.js index fd5c9c93dfa..7384fe1e5f5 100644 --- a/addons/auth_signup/static/src/js/auth_signup.js +++ b/addons/auth_signup/static/src/js/auth_signup.js @@ -4,7 +4,7 @@ openerp.auth_signup = function(instance) { instance.web.Login.include({ start: function() { var self = this; - + this.$('a.oe_signup').click(function() { var db = self.$("form [name=db]").val(); if (!db) { @@ -32,17 +32,74 @@ openerp.auth_signup = function(instance) { _signup: function() { this.do_action({ - type:'ir.actions.act_window', - res_model: 'auth.signup', - views: [[false, 'form']], + type: 'ir.actions.client', + tag: 'auth_signup.signup', target: 'new', - name: 'Sign Up' - }, function() { - // mmh, no way to have access to dialog befor close... - // TODO autolog user - console.log('onclose', this, arguments); + name: 'Sign up' }); } }); + + instance.auth_signup = instance.auth_signup || {}; + instance.auth_signup.Signup = instance.web.Widget.extend({ + template: 'auth_signup.signup', + init: function() { + this._super.apply(this, arguments); + this.dataset = new instance.web.DataSet(this, 'auth.signup'); + }, + start: function() { + var self = this; + this.$('input[type=password]').change(function() { + var v = $(this).val(); + var e = !_.isEmpty(v); + if (e) { + e =_.all(self.$('input[type=password]'), function(i) { + return $(i).val() === v; + }); + } + var $b = self.$('button'); + if (e) { + $b.removeAttr('disabled'); + } else { + $b.attr('disabled', 'disabled'); + } + }); + + this.$('form').submit(function(ev) { + if(ev) { + ev.preventDefault(); + } + var name = self.$('input[name=name]').val(); + var email = self.$('input[name=email]').val(); + var password = self.$('input[name=password]').val(); + + self.dataset.create({ + name: name, + email: email, + password: password + }, function() { + self.do_action({ + type: 'ir.actions.client', + tag: 'login', + params: { + db: instance.connection.db, + login: email, + password: password, + login_successful: function() { + self.do_action('home'); + } + } + }); + }); + return false; + + }); + return $.when(this._super()); + } + + }); + instance.web.client_actions.add("auth_signup.signup", "instance.auth_signup.Signup"); + + }; diff --git a/addons/auth_signup/static/src/xml/auth_signup.xml b/addons/auth_signup/static/src/xml/auth_signup.xml index df24bca3ef1..92343d96281 100644 --- a/addons/auth_signup/static/src/xml/auth_signup.xml +++ b/addons/auth_signup/static/src/xml/auth_signup.xml @@ -11,6 +11,18 @@ + + + + Name = + Email = + Password = + Confirmation = + Signup + + + +