Include accountname in totp url
[mirror/userdir-ldap-cgi.git] / fetch-totp-seed.cgi
index 322908a..3bcc447 100644 (file)
@@ -26,12 +26,14 @@ if ($timestamp + 1800 < time()) {
 my $filename = $config{totpticketdirectory} . "/" . $random_id;
 open(my $fh, "<", $filename) or &Util::HTMLError("TOTP seed file not found or permission denied: $! ; $filename");
 my $hex_seed = <$fh>;
+chomp $hex_seed;
 my $accountname = <$fh>;
-my $seed = encode_base32(pack('H*', hex_seed));
+chomp $accountname;
+my $seed = encode_base32(pack('H*', $hex_seed));
 close $fh;
 #unlink $filename;
 
-my $totpurl = "otpauth://totp/Debian?secret=$seed&issuer=Debian";
+my $totpurl = "otpauth://totp/Debian:$accountname?secret=$seed&issuer=Debian";
 my $totppng = "data:image/png;base64, " .
        encode_base64(GD::Barcode::QRcode->new($totpurl,
                                               { ModuleSize => 10 })->plot->png);