Ejemplo n.º 1
0
    def modify_totp(username, password):
        """
        Update the TOTP secret
        """
        resp = Response("OK")

        if UserManager.verify_match(username, password):
            try:
                totp_secret = UserManager._reset_totp(username)

                otpauth_link = 'otpauth://totp/%s?secret=%s' % (username,
                                                                totp_secret)
                qr_code = pyqrcode.create(otpauth_link)

                template_args = {
                    'username': username,
                    'totp_secret': totp_secret,
                    'qr_blob': qr_code.png_as_base64_str(scale=5)
                }

                mako_template = LOOKUP.get_template('modify_totp.mako')
                resp.message = mako_template.render(**template_args)
            except RuntimeError:
                resp = BadRequest("Username not found")
        else:
            resp = BadRequest("Username/password mismatch")
        return resp
Ejemplo n.º 2
0
    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