Example #1
0
 def post(self):
     id = self.request.get('id')
     secret = self.request.get('secret')
     otp_secret = OtpSecret(id=int(id), secret=secret,
                            moving_factor=0,
                            owner=users.get_current_user())
     otp_secret.put()
     self.redirect('/list')
Example #2
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))
Example #3
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
Example #4
0
 def get(self):
     OtpSecret.get(db.Key(self.request.get('key'))).delete()
     self.redirect('/list')