aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Auth/GoogleAuth.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Auth/GoogleAuth.pm')
-rw-r--r--perllib/FixMyStreet/Auth/GoogleAuth.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Auth/GoogleAuth.pm b/perllib/FixMyStreet/Auth/GoogleAuth.pm
new file mode 100644
index 000000000..ffe58b2dd
--- /dev/null
+++ b/perllib/FixMyStreet/Auth/GoogleAuth.pm
@@ -0,0 +1,27 @@
+package FixMyStreet::Auth::GoogleAuth;
+
+use parent 'Auth::GoogleAuth';
+
+use strict;
+use warnings;
+use Image::PNG::QRCode 'qrpng';
+use URI;
+
+# Overridden to return a data: URI of the image
+sub qr_code {
+ my $self = shift;
+ my ( $secret32, $key_id, $issuer, $return_otpauth ) = @_;
+
+ # Make issuer a bit nicer to read
+ $issuer =~ s{https?://}{};
+
+ my $otpauth = $self->SUPER::qr_code($secret32, $key_id, $issuer, 1);
+ return $otpauth if $return_otpauth;
+
+ my $u = URI->new('data:');
+ $u->media_type('image/png');
+ $u->data(qrpng(text => $otpauth));
+ return $u;
+}
+
+1;