def activate(self, email, code): reg = Registration.get_inactive(email, code) if not reg: flash(_('Registration not found or already activated')) return redirect(self.mount_point) u = app_model.User(user_name=reg.user_name, display_name=reg.user_name, email_address=reg.email_address, password=reg.password) hooks = config['hooks'].get('registration.before_activation', []) for func in hooks: func(reg, u) DBSession.add(u) reg.user = u reg.password = '******' reg.activated = datetime.now() hooks = config['hooks'].get('registration.after_activation', []) for func in hooks: func(reg, u) flash(_('Account succesfully activated')) return redirect('/')
def out_of_uow_flush(self, entity=None): DBSession.add(entity) try: DBSession.flush() except IntegrityError: transaction.doom() raise DalIntegrityError return entity
def new(self, **kw): new_reg = Registration() new_reg.email_address = kw['email_address'] new_reg.user_name = kw['user_name'] new_reg.password = kw['password'] new_reg.code = Registration.generate_code(kw['email_address']) DBSession.add(new_reg) DBSession.flush() return new_reg
def submit(self, *args, **kw): hooks = config['hooks'].get('registration.before_registration', []) for func in hooks: func(kw) new_reg = Registration() new_reg.email_address = kw['email_address'] new_reg.user_name = kw['user_name'] new_reg.password = kw['password'] new_reg.code = Registration.generate_code(kw['email_address']) DBSession.add(new_reg) DBSession.flush() hooks = config['hooks'].get('registration.after_registration', []) for func in hooks: func(new_reg, kw) return redirect(url(self.mount_point + '/complete', params=dict(code=new_reg.code, email=new_reg.email_address)))