Exemplo n.º 1
0
 def get(self):
     template_values = {'secrets': OtpSecret.all().filter('owner',
                        users.get_current_user()).order('id'),
                        'logout_url': users.create_logout_url(self.request.uri)}
     path = os.path.join(os.path.dirname(__file__),
                         'templates/list.html')
     self.response.out.write(template.render(path, template_values))
Exemplo n.º 2
0
 def post(self):
     request = self.request
     status = '<span style="color: red">wrong password</span>'
     password = request.get('password')
     if request.get('id') and password:
         id = int(request.get('id'))
         secrets = OtpSecret.all().filter('owner',
                 users.get_current_user()).filter('id', id)
         if secrets:
             for secret in secrets:
                 for loop in range(0, 10):
                     try:
                         actual = secret.moving_factor + loop
                         genpin = hotp.hotp(secret.secret, actual)
                     except Exception, err:
                         break
                     if genpin == password:
                         status = 'OK'
                         secret.moving_factor = actual + 1
                         secret.put()
                         break