Esempio n. 1
0
 def _make_token(self, user, ts, key=None):
     ts_b62 = int_to_base62(ts)
     if key is None:
         key = "pyramid_spine.tokens.TokenGenerator"
     value = unicode(user.id) + user.password + unicode(ts)
     hash = hmac.new(key, value, digestmod=hashlib.sha1).hexdigest()
     return "%s-%s" % (ts_b62, hash)
Esempio n. 2
0
    def save(self, request):
        mailer = get_mailer(request)
        settings = request.registry.settings

        subject = 'Password reset for buckit.io'
        base_id = int_to_base62(self.user.id)
        token = token_generator.create_token(self.user)
        context = {
            'domain': 'buckit.io',
            'protocol': 'https',
            'base_id': base_id,
            'token': token
        }
        body = render('spine/password_reset_email.html', context, request=request)
        message = Message(
            subject=subject,
            sender=settings.get('mail_sender'),
            recipients=[self.email.data],
            body=body)
        mailer.send(message)