Newer
Older
Generate the TOTP PNG QRcode image ready to scan.
"""
current_app.logger.info( "Generate the TOTP QRcode" )
if "username" in session:
qrcode_value = "otpauth://totp/ICNML%20{}?secret={}&issuer=ICNML".format( session[ "username" ], get_secret() )
qrcode_value = "otpauth://totp/ICNML?secret={}&issuer=ICNML".format( get_secret() )
current_app.logger.debug( "Value: {}".format( qrcode_value ) )
img = qrcode.make( qrcode_value )
temp = StringIO()
img.save( temp, format = "png" )
temp.seek( 0 )
return send_file( temp, mimetype = "image/png" )
@login_view.route( "/user/config/totp" )
def user_totp_config():
"""
Serve the TOTP configuration page.
"""
current_app.logger.info( "Serve the TOTP config page" )
return utils.template.my_render_template(
"users/totp.html",
secret = get_secret()
)