openerp.auth_oauth = function(instance) {
+ var _t = instance.web._t,
+ _lt = instance.web._lt;
var QWeb = instance.web.qweb;
instance.web.Login.include({
this.$el.on('click', 'a.zocial', this.on_oauth_sign_in);
this.oauth_providers = [];
if(this.params.oauth_error === 1) {
- this.do_warn("Sign up error.","Sign up is not allowed on this database.");
+ this.do_warn(_t("Sign up error"),_t("Sign up is not allowed on this database."), true);
} else if(this.params.oauth_error === 2) {
- this.do_warn("Authentication error","");
+ this.do_warn(_t("Authentication error"),_t("Access Denied"), true);
+ } else if(this.params.oauth_error === 3) {
+ this.do_warn(_t("Authentication error"),_t("You do not have access to this database or your invitation has expired. Please ask for an invitation and be sure to follow the link in your invitation email."), true);
}
return d.done(this.do_oauth_load).fail(function() {
self.do_oauth_load([]);
import simplejson
import openerp
+from openerp.addons.auth_signup.res_users import SignupError
from openerp.osv import osv, fields
_logger = logging.getLogger(__name__)
try:
login = super(res_users, self)._auth_oauth_signin(cr, uid, provider, validation, params, context=context)
- except openerp.exceptions.AccessDenied:
+ except openerp.exceptions.AccessDenied, access_denied_exception:
if context and context.get('no_user_creation'):
return None
state = simplejson.loads(params['state'])
'oauth_access_token': params['access_token'],
'active': True,
}
- _, login, _ = self.signup(cr, uid, values, token, context=context)
-
+ try:
+ _, login, _ = self.signup(cr, uid, values, token, context=context)
+ except SignupError:
+ raise access_denied_exception
return login
from openerp.osv import osv, fields
from openerp.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
-from openerp.tools.safe_eval import safe_eval
+from ast import literal_eval
from openerp.tools.translate import _
class SignupError(Exception):
def _signup_create_user(self, cr, uid, values, context=None):
""" create a new user from the template user """
ir_config_parameter = self.pool.get('ir.config_parameter')
- template_user_id = safe_eval(ir_config_parameter.get_param(cr, uid, 'auth_signup.template_user_id', 'False'))
+ template_user_id = literal_eval(ir_config_parameter.get_param(cr, uid, 'auth_signup.template_user_id', 'False'))
assert template_user_id and self.exists(cr, uid, template_user_id, context=context), 'Signup: invalid template user'
# check that uninvited users may sign up
if 'partner_id' not in values:
- if not safe_eval(ir_config_parameter.get_param(cr, uid, 'auth_signup.allow_uninvited', 'False')):
+ if not literal_eval(ir_config_parameter.get_param(cr, uid, 'auth_signup.allow_uninvited', 'False')):
raise SignupError('Signup is not allowed for uninvited users')
assert values.get('login'), "Signup: no login given for new user"