Exemple #1
0
 def POST(self, **kwargs):
     """accepts a username and initiates a reset"""
     errors = check_captcha(kwargs)
     if not errors and not kwargs['username']:
         errors = "Username is required"
     if errors:
         return render('request_reset.html', errors=errors, captcha=captcha_helper.CaptchaHelper())
     r = PasswordReset(kwargs['username'])
     r.save()
     if r.check_valid():
         ResetPasswordMailer(r).mail()
     raise cherrypy.HTTPRedirect('/complete')
 def POST(self, **params):
     if 'username' not in params or 'token' not in params:
         return render('reset_password.html',
                       username=params.get('username', ''),
                       token=params.get('token', ''),
                       error='All fields are required')
     else:
         p = PasswordReset.load(params['username'])
         if p is not None and p.token == params['token']:
             new_pass = p.reset_password()
             PasswordReset.expire(params['username'])
             return render('display_password.html', password=new_pass)
         else:
             PasswordReset.expire(params['username'])
             return render('invalid_token.html')
 def POST(self, **params):
     if 'username' not in params or 'token' not in params:
         return render('reset_password.html',
             username=params.get('username',''),
             token=params.get('token',''),
             error='All fields are required'
         )
     else:
         p = PasswordReset.load(params['username'])
         if p is not None and p.token == params['token']:
             new_pass = p.reset_password()
             PasswordReset.expire(params['username'])
             return render('display_password.html', password=new_pass)
         else:
             PasswordReset.expire(params['username'])
             return render('invalid_token.html')