Beispiel #1
0
    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('/')
Beispiel #2
0
    def complete(self, email, code):
        reg = Registration.get_inactive(email, code)
        if not reg:
            flash(_('Registration not found or already activated'))
            return redirect(self.mount_point)

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

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

        hooks = config['hooks'].get('registration.on_complete', [])
        for func in hooks:
            func(email_data)

        send_email(email, email_data['sender'], email_data['subject'], email_data['body'])

        return dict(email=email, email_data=email_data)