+(function() {
+const img = document.getElementById("$id_js"),
+ body = "str=" + encodeURIComponent("$str_js");
+fetch("$url_js", {
+ method: "POST",
+ body: body
+ }).then(function(response) {
+ if (!response.ok) { return null; }
+ return response.blob();
+ }).then(function(blob) {
+ if (!blob) { return; }
+ const reader = new FileReader();
+ reader.onloadend = function() { img.src = reader.result; };
+ reader.readAsDataURL(blob);
+ }).catch(function() { });
+})();
+
+
+EOF
}
else {
- $url = "https://api.qrserver.com/v1/create-qr-code/?".
- "size=200x200&data=".&urlize($str);
+ my $url = "https://api.qrserver.com/v1/create-qr-code/?".
+ "size=200x200&data=".&urlize($str);
+ my $img = &ui_tag('img', undef,
+ { 'src' => $url, 'border' => 0, 'alt' => 'QR code' });
+ return <
+EOF
}
-my $rv;
-$rv .= &text('twofactor_qrcode', "$user->{'twofactor_id'}")."\n";
-$rv .= "
\n";
-return $rv;
}
# validate_twofactor_totp(id, token)