diff --git a/lemonldap-ng-portal/MANIFEST b/lemonldap-ng-portal/MANIFEST
index 541cb12cc..d93949b89 100644
--- a/lemonldap-ng-portal/MANIFEST
+++ b/lemonldap-ng-portal/MANIFEST
@@ -536,6 +536,7 @@ t/76-2F-Ext-with-BruteForce.t
t/76-2F-Ext-with-CodeActivation.t
t/76-2F-Ext-with-GrantSession.t
t/76-2F-Ext-with-History.t
+t/77-2F-Mail-with-global-storage.t
t/77-2F-Mail.t
t/90-Translations.t
t/99-pod.t
diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/OneTimeToken.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/OneTimeToken.pm
index 2539c4724..558891188 100644
--- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/OneTimeToken.pm
+++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/OneTimeToken.pm
@@ -5,7 +5,7 @@ use Mouse;
use JSON qw(from_json to_json);
use Crypt::URandom;
-our $VERSION = '2.0.2';
+our $VERSION = '2.0.4';
extends 'Lemonldap::NG::Common::Module';
@@ -134,7 +134,11 @@ sub updateToken {
return $id;
}
else {
- $self->p->getApacheSession( $id, $k => $v );
+ $self->p->getApacheSession(
+ $id,
+ kind => "TOKEN",
+ info => { $k => $v }
+ );
return $id;
}
}
diff --git a/lemonldap-ng-portal/t/77-2F-Mail-with-global-storage.t b/lemonldap-ng-portal/t/77-2F-Mail-with-global-storage.t
new file mode 100644
index 000000000..0e8c9cd89
--- /dev/null
+++ b/lemonldap-ng-portal/t/77-2F-Mail-with-global-storage.t
@@ -0,0 +1,70 @@
+use Test::More;
+use strict;
+use IO::String;
+use Data::Dumper;
+
+require 't/test-lib.pm';
+require 't/smtp.pm';
+
+use_ok('Lemonldap::NG::Common::FormEncode');
+count(1);
+
+my $client = LLNG::Manager::Test->new( {
+ ini => {
+ logLevel => 'error',
+ mail2fActivation => 1,
+ mail2fCodeRegex => '\d{4}',
+ authentication => 'Demo',
+ userDB => 'Same',
+ tokenUseGlobalStorage => 1,
+ }
+ }
+);
+
+# Try to authenticate
+# -------------------
+ok(
+ my $res = $client->_post(
+ '/',
+ IO::String->new('user=dwho&password=dwho'),
+ length => 23,
+ accept => 'text/html',
+ ),
+ 'Auth query'
+);
+count(1);
+
+my ( $host, $url, $query ) =
+ expectForm( $res, undef, '/mail2fcheck', 'token', 'code' );
+
+ok(
+ $res->[2]->[0] =~
+qr%%,
+ 'Found EXTCODE input'
+) or print STDERR Dumper( $res->[2]->[0] );
+count(1);
+
+ok( mail() =~ m%(\d{4})%, 'Found 2F code in mail' )
+ or print STDERR Dumper( mail() );
+
+my $code = $1;
+count(1);
+
+$query =~ s/code=/code=${code}/;
+ok(
+ $res = $client->_post(
+ '/mail2fcheck',
+ IO::String->new($query),
+ length => length($query),
+ accept => 'text/html',
+ ),
+ 'Post code'
+);
+count(1);
+my $id = expectCookie($res);
+$client->logout($id);
+
+clean_sessions();
+
+done_testing( count() );
+