Ejemplo n.º 1
0
    def index(self, *args, **kw):
        try:
            log.info('User registration: %s'%str(kw))
            new_reg = Registration()
            new_reg.email_address = kw['email_address']
            new_reg.user_name = kw['email_address']
            new_reg.password = kw['password']
            new_reg.code = Registration.generate_code(kw['email_address'])
            DBSession.add(new_reg)
            DBSession.flush()

            email_data = {'sender':config['registration.email_sender'],
                      'subject':_('Message from Jminee'),
                      'body':'''
Please click on this link to confirm your registration

%s
''' % (url_for(self.mount_point+'/activate', code=new_reg.code, email=new_reg.email_address, qualified=True))}

        
            send_email(new_reg.email_address, email_data['sender'], email_data['subject'], email_data['body'])
        except Exception as e:
            log.exception('Got exception')
            return dict(success=False)
        return dict(success=True, email=kw['email_address'])