From 832eb08b906d39f35546465c4bbeec332da19478 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 30 Oct 2024 21:24:06 -0700 Subject: [PATCH] Usermin also needs a version of qr.cgi https://github.com/webmin/usermin/issues/116 --- twofactor/lang/en | 3 +++ twofactor/qr.cgi | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 twofactor/qr.cgi diff --git a/twofactor/lang/en b/twofactor/lang/en index afc61ea2..d8c72124 100644 --- a/twofactor/lang/en +++ b/twofactor/lang/en @@ -36,3 +36,6 @@ twofactor_etotpmatch=Incorrect OTP code enable_title=Enabled Two-Factor Authentication enable_err=Enrollment failed + +qr_err=Failed to generate QR code +qr_estr=Missing QR code string! diff --git a/twofactor/qr.cgi b/twofactor/qr.cgi new file mode 100755 index 00000000..4b6c7a95 --- /dev/null +++ b/twofactor/qr.cgi @@ -0,0 +1,20 @@ +#!/usr/local/bin/perl +# Show a QR code based on parameters + +use strict; +use warnings; +no warnings 'redefine'; +no warnings 'uninitialized'; +$main::no_acl_check = 1; +require './twofactor-lib.pl'; + +our (%in, %text, %gconfig, %config); +&ReadParse(); +&error_setup($text{'qr_err'}); + +$in{'str'} || &error($text{'qr_estr'}); +my ($img, $mime) = &generate_qr_code($in{'str'}, $in{'size'}); +$img || &error($mime); + +&PrintHeader(undef, $mime); +print $img;