def modify_password(username, password, newpassword): """ Update the password """ resp = Response("OK") if UserManager.verify_match(username, password): """ Update the password """ try: usernm = UserManager._update_password(username, newpassword) mako_template = LOOKUP.get_template('modify_pwd.mako') except RuntimeError: resp = BadRequest("Username not found") return False, resp else: resp = BadRequest("Username/password mismatch") return False, resp return True, resp
def update_password(self, newpassword, url): """ Updates the password :param username: Username given by the user :param newpassword: New Password selected by the user """ resp = Response("OK") try: usernm = UserManager._update_password(self.username, newpassword) # mako_template = LOOKUP.get_template(self.mako_template3) except RuntimeError: resp = BadRequest("Username %s not found" % self.username) """ Update the TOTP secret """ try: totp_secret = UserManager._reset_totp(self.username) otpauth_link = 'otpauth://totp/%s?secret=%s' % (self.username, totp_secret) qr_code = pyqrcode.create(otpauth_link) template_args = { 'username': self.username, 'totp_secret': totp_secret, 'qr_blob': qr_code.png_as_base64_str(scale=5), 'home_url': url } mako_template = LOOKUP.get_template('modify_totp.mako') resp.message = mako_template.render(**template_args) except RuntimeError: resp = BadRequest("Username not found") return resp