diff options
author | Marius Halden <marius.h@lden.org> | 2020-09-29 14:23:52 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2020-09-29 14:23:52 +0200 |
commit | a27ce1524d801d2742a2bdb6ec1da45126d64353 (patch) | |
tree | 64123c4e17dc1776aa0a7cd65ee01d49d3e7d978 /perllib/FixMyStreet/Auth/GoogleAuth.pm | |
parent | 377bd96aab7cad3434185c30eb908c9da447fe40 (diff) | |
parent | 2773c60226b9370fe8ee00f7b205b571bb87c3b5 (diff) |
Merge tag 'v3.0.1' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/Auth/GoogleAuth.pm')
-rw-r--r-- | perllib/FixMyStreet/Auth/GoogleAuth.pm | 27 |
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; |