[MERGE] trunk-improve_signup-vta
bzr revid: al@openerp.com-20121218161650-dp5t9ky39wpcp4b6
This commit is contained in:
@@ -28,9 +28,14 @@ openerp.auth_oauth = function(instance) {
|
||||
},
|
||||
on_oauth_loaded: function(result) {
|
||||
this.oauth_providers = result;
|
||||
this.$('.oe_oauth_provider_login_button').remove();
|
||||
var buttons = QWeb.render("auth_oauth.Login.button",{"widget":this});
|
||||
this.$(".oe_login_pane form ul").after(buttons);
|
||||
var params = $.deparam($.param.querystring());
|
||||
if (this.oauth_providers.length === 1 && params.type === 'signup') {
|
||||
this.do_oauth_sign_in(this.oauth_providers[0]);
|
||||
} else {
|
||||
this.$('.oe_oauth_provider_login_button').remove();
|
||||
var buttons = QWeb.render("auth_oauth.Login.button",{"widget":this});
|
||||
this.$(".oe_login_pane form ul").after(buttons);
|
||||
}
|
||||
},
|
||||
on_oauth_sign_in: function(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
@@ -64,7 +64,7 @@ class res_partner(osv.Model):
|
||||
|
||||
# the parameters to encode for the query and fragment part of url
|
||||
query = {'db': cr.dbname}
|
||||
fragment = {'action': action}
|
||||
fragment = {'action': action, 'type': partner.signup_type}
|
||||
|
||||
if partner.signup_token:
|
||||
fragment['token'] = partner.signup_token
|
||||
@@ -91,6 +91,7 @@ class res_partner(osv.Model):
|
||||
|
||||
_columns = {
|
||||
'signup_token': fields.char('Signup Token'),
|
||||
'signup_type': fields.char('Signup Token Type'),
|
||||
'signup_expiration': fields.datetime('Signup Expiration'),
|
||||
'signup_valid': fields.function(_get_signup_valid, type='boolean', string='Signup Token is Valid'),
|
||||
'signup_url': fields.function(_get_signup_url, type='char', string='Signup URL'),
|
||||
@@ -99,7 +100,7 @@ class res_partner(osv.Model):
|
||||
def action_signup_prepare(self, cr, uid, ids, context=None):
|
||||
return self.signup_prepare(cr, uid, ids, context=context)
|
||||
|
||||
def signup_prepare(self, cr, uid, ids, expiration=False, context=None):
|
||||
def signup_prepare(self, cr, uid, ids, signup_type="signup", expiration=False, context=None):
|
||||
""" generate a new token for the partners with the given validity, if necessary
|
||||
:param expiration: the expiration datetime of the token (string, optional)
|
||||
"""
|
||||
@@ -108,7 +109,7 @@ class res_partner(osv.Model):
|
||||
token = random_token()
|
||||
while self._signup_retrieve_partner(cr, uid, token, context=context):
|
||||
token = random_token()
|
||||
partner.write({'signup_token': token, 'signup_expiration': expiration})
|
||||
partner.write({'signup_token': token, 'signup_type': signup_type, 'signup_expiration': expiration})
|
||||
return True
|
||||
|
||||
def _signup_retrieve_partner(self, cr, uid, token,
|
||||
@@ -182,7 +183,7 @@ class res_users(osv.Model):
|
||||
partner = res_partner._signup_retrieve_partner(
|
||||
cr, uid, token, check_validity=True, raise_exception=True, context=None)
|
||||
# invalidate signup token
|
||||
partner.write({'signup_token': False, 'signup_expiration': False})
|
||||
partner.write({'signup_token': False, 'signup_type': False, 'signup_expiration': False})
|
||||
|
||||
partner_user = partner.user_ids and partner.user_ids[0] or False
|
||||
if partner_user:
|
||||
@@ -240,7 +241,7 @@ class res_users(osv.Model):
|
||||
# prepare reset password signup
|
||||
res_partner = self.pool.get('res.partner')
|
||||
partner_ids = [user.partner_id.id for user in self.browse(cr, uid, ids, context)]
|
||||
res_partner.signup_prepare(cr, uid, partner_ids, expiration=now(days=+1), context=context)
|
||||
res_partner.signup_prepare(cr, uid, partner_ids, signup_type="reset", expiration=now(days=+1), context=context)
|
||||
|
||||
# send email to users with their signup url
|
||||
template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'reset_password_email')
|
||||
@@ -248,7 +249,7 @@ class res_users(osv.Model):
|
||||
for user in self.browse(cr, uid, ids, context):
|
||||
if not user.email:
|
||||
raise osv.except_osv(_("Cannot send email: user has no email address."), user.name)
|
||||
self.pool.get('email.template').send_mail(cr, uid, template.id, user.id, context=context)
|
||||
self.pool.get('email.template').send_mail(cr, uid, template.id, user.id, True, context=context)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ openerp.auth_signup = function(instance) {
|
||||
.fail(self.on_token_failed)
|
||||
});
|
||||
}
|
||||
if (self.params.db && self.params.login) {
|
||||
this.$("form input[name=login]").val(self.params.login);
|
||||
}
|
||||
|
||||
// bind reset password link
|
||||
this.$('a.oe_signup_reset_password').click(this.do_reset_password);
|
||||
@@ -130,7 +133,7 @@ openerp.auth_signup = function(instance) {
|
||||
login: login,
|
||||
password: password,
|
||||
};
|
||||
|
||||
|
||||
var self = this,
|
||||
super_ = this._super;
|
||||
this.rpc('/auth_signup/signup', params)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="name">res_partner: read access on my partner</field>
|
||||
<field name="model_id" ref="base.model_res_partner"/>
|
||||
<field name="domain_force">[('user_ids', 'in', user.id)]</field>
|
||||
<field name="groups" eval="[(4, ref('group_portal'))]"/>
|
||||
<field name="groups" eval="[(4, ref('group_portal')), (4, ref('group_anonymous'))]"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_mail_message_portal,mail.message.portal,mail.model_mail_message,portal.group_anonymous,1,0,0,0
|
||||
access_res_partner,res.partner,base.model_res_partner,portal.group_anonymous,1,0,0,0
|
||||
access_res_partner_category,res.partner_category,base.model_res_partner_category,portal.group_anonymous,1,0,0,0
|
||||
access_res_partner_title,res.partner_title,base.model_res_partner_title,portal.group_anonymous,1,0,0,0
|
||||
|
||||
|
@@ -4,13 +4,13 @@ openerp.portal_anonymous = function(instance) {
|
||||
start: function() {
|
||||
var self = this;
|
||||
return $.when(this._super()).then(function() {
|
||||
var params = $.deparam($.param.querystring());
|
||||
var dblist = self.db_list || [];
|
||||
if (!self.session.session_is_valid() && dblist.length === 1) {
|
||||
if (!self.session.session_is_valid() && dblist.length === 1 && (!params.token || !params.login)) {
|
||||
self.remember_credentials = false;
|
||||
// XXX get login/pass from server (via a rpc call) ?
|
||||
return self.do_login(dblist[0], 'anonymous', 'anonymous');
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -51,6 +51,14 @@ openerp.portal_anonymous = function(instance) {
|
||||
}
|
||||
return false;
|
||||
},
|
||||
// Avoid browser preloading
|
||||
show_application: function() {
|
||||
var params = $.deparam($.param.querystring());
|
||||
if (!!params.token || !!params.login) {
|
||||
return this.show_login();
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user