def password_policy(self, cr, uid, new_passwd): users = self.pool.get('user.password.policy') user_obj = self.browse(cr, uid, uid) if re.match(r'[A-Za-z0-9@#$%^&+=]{8,}', new_passwd): user = users.search(cr, SUPERUSER_ID, [('user_id', '=', uid)]) split_new_pass = re.split(r'[0-9@#$%^&+=.]', new_passwd) split_username = re.split(r'[0-9@#$%^&+=.]', str(user_obj.login)) for split in split_new_pass: if split.lower() == split_username[0].lower(): raise SignupError( _(u'Нууц үгийн урт 8-аас дээш тэмдэгтээс бүтсэн, том жижиг үсэг, тоо, тусгай тэмдэгт ашигласан байх шаардлагатай.' )) if user: users.check_password(cr, uid, user[0], new_passwd) else: users.create(cr, SUPERUSER_ID, { 'sequence': '1', 'user_id': uid, 'first_password': new_passwd }) return else: raise SignupError( _(u'Нууц үгийн урт 8-аас дээш тэмдэгтээс бүтсэн, том жижиг үсэг, тоо, тусгай тэмдэгт ашигласан байх шаардлагатай.' ))
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 = 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 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" assert values.get('partner_id') or values.get( 'name'), "Signup: no name or partner given for new user" values['active'] = True context = dict(context or {}, no_reset_password=True) values2 = dict() if values.get('l10n_mx_street3', False): values2['l10n_mx_street3'] = values['l10n_mx_street3'] del values['l10n_mx_street3'] if values.get('l10n_mx_street4', False): values2['l10n_mx_street4'] = values['l10n_mx_street4'] del values['l10n_mx_street4'] if values.get('zip_sat_id', False): values2['zip_sat_id'] = values['zip_sat_id'] del values['zip_sat_id'] if values.get('township_sat_id', False): values2['township_sat_id'] = values['township_sat_id'] del values['township_sat_id'] if values.get('locality_sat_id', False): values2['locality_sat_id'] = values['locality_sat_id'] del values['locality_sat_id'] try: with cr.savepoint(): new_user_id = self.copy( cr, uid, template_user_id, values, context=context) try: self.write(cr, uid, new_user_id, values2, context=context) except Exception: pass return new_user_id except Exception, e: # copy may failed if asked login is not available. raise SignupError(ustr(e))
def signup(self, values, token=None, context=None): try: users = self.search([('login', '=', values["login"])]) if len(users) > 0: raise Exception( 'Este e-mail já está cadastrado em nosso sistema.') created_user = super(res_users, self).signup(values, token) user = self.search([('login', '=', created_user[1])])[0] user.partner_id.gender = values[ "gender"] if "gender" in values else False user.partner_id.profile = values[ "profile"] if "profile" in values else False user.partner_id.date_birth = values[ "date_birth"] if "date_birth" in values else False user.partner_id.date_birth = values[ "join_events"] if "join_events" in values else False config = self.env['base.config.settings'].search([]) if len(config) > 0 and config.signup_email_template_id.id: mail_template = config.signup_email_template_id mail_template.send_mail(self.id, force_send=True, raise_exception=True) return created_user except Exception as e: raise SignupError(e.message or str(e))
def _signup_with_values(self, token, values): db, login, password = request.registry['res.users'].signup( request.cr, openerp.SUPERUSER_ID, values, token) request.cr.commit( ) # as authenticate will use its own cursor we need to commit the current transaction uid = request.session.authenticate(db, login, password) if not uid: raise SignupError(_('Authentication Failed.'))
def signup(self, values, token=None): """ Added for password validation: at least 6 characters, any letters, any uppercase letter, not only lowercase. You can't do it using constraints, as password is hashed in the database. """ if not self._is_password_safe(values.get('password')): raise SignupError("Hasło powinno zawierać co najmniej 6 znaków, w tym litery różnej wielkości!") return super(Volunteer, self).signup(values, token)
def do_signup(self, qcontext): values = dict((key, qcontext.get(key)) for key in ('login', 'name', 'password')) assert any([k for k in values.values()]), "The form was not properly filled in." assert values.get('password') == qcontext.get('confirm_password'), "Passwords do not match; please retype them." if qcontext.get('token'): return super(AuthSignupHome, self).do_signup(qcontext) else: try: request.registry['cec.alumnos'].create(request.cr, openerp.SUPERUSER_ID, {'name': values.get('name'), 'email': values.get('login')}, {"password": values.get('password')}) request.cr.commit() except Exception, e: raise SignupError(ustr(e))
def change_password(self, cr, uid, old_passwd, new_passwd, context=None): """Change current user password. Old password must be provided explicitly to prevent hijacking an existing user session, or for cases where the cleartext password is not used to authenticate requests. :return: True :raise: openerp.exceptions.AccessDenied when old password is wrong :raise: except_osv when new password is not set or empty """ self.check(cr.dbname, uid, old_passwd) self.password_policy(cr, uid, new_passwd) if new_passwd: return self.write(cr, uid, uid, {'password': new_passwd}) raise SignupError( _(u'Нууц үгийн урт 8-аас дээш тэмдэгтээс бүтсэн, том жижиг үсэг, тоо, тусгай тэмдэгт ашигласан байх шаардлагатай.' ))
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 = 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 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" assert values.get('partner_id') or values.get('name'), "Signup: no name or partner given for new user" # create a copy of the template user (attached to a specific partner_id if given) values['active'] = False return self.copy(cr, uid, template_user_id, values, context=context)
assert values.get('password') == qcontext.get('confirm_password'), "Passwords do not match; please retype them." if qcontext.get('token'): return super(AuthSignupHome, self).do_signup(qcontext) else: try: request.registry['cec.docentes'].create(request.cr, openerp.SUPERUSER_ID, {'name': values.get('name'), 'email': values.get('login')}, {"password": values.get('password')}) request.cr.commit() except Exception, e: raise SignupError(ustr(e)) print request.cr.dbname uid = request.session.authenticate(request.cr.dbname, values.get('login'), values.get('password')) if not uid: raise SignupError(_('Authentification Failed.')) def do_signup(self, qcontext): values = dict((key, qcontext.get(key)) for key in ('login', 'name', 'password')) assert any([k for k in values.values()]), "The form was not properly filled in." assert values.get('password') == qcontext.get('confirm_password'), "Passwords do not match; please retype them." if qcontext.get('token'): return super(AuthSignupHome, self).do_signup(qcontext) else: try: request.registry['cec.alumnos'].create(request.cr, openerp.SUPERUSER_ID, {'name': values.get('name'), 'email': values.get('login')}, {"password": values.get('password')}) request.cr.commit() except Exception, e: