diff --git a/html/captive-portal/lib/captiveportal/Base/Actions.pm b/html/captive-portal/lib/captiveportal/Base/Actions.pm
index 400ac86fc1f1..518d81f71362 100644
--- a/html/captive-portal/lib/captiveportal/Base/Actions.pm
+++ b/html/captive-portal/lib/captiveportal/Base/Actions.pm
@@ -39,6 +39,7 @@ our %AUTHENTICATION_ACTIONS = (
on_failure => sub {},
on_success => sub {},
destination_url => sub {$_[0]->app->session->{destination_url} = $_[1];$_[0]->app->session->{portal_module_force_destination_url} = $TRUE},
+ unregdate_from_sponsor_source => sub { $_[0]->new_node_info->{unregdate} = $_[0]->session->{unregdate} if defined($_[0]->session->{unregdate}) },
);
=head2 authentication_match_wrapper
diff --git a/html/captive-portal/lib/captiveportal/PacketFence/Controller/Activate/Email.pm b/html/captive-portal/lib/captiveportal/PacketFence/Controller/Activate/Email.pm
index 2bd49d00ffe6..5d4d0caea71d 100644
--- a/html/captive-portal/lib/captiveportal/PacketFence/Controller/Activate/Email.pm
+++ b/html/captive-portal/lib/captiveportal/PacketFence/Controller/Activate/Email.pm
@@ -124,6 +124,22 @@ sub login : Private {
);
}
+=head2 choose_access_duration
+
+=cut
+
+sub choose_access_duration : Private {
+ my ( $self, $c ) = @_;
+ if ( $c->has_errors ) {
+ $c->stash->{txt_auth_error} = join(' ', grep { ref ($_) eq '' } @{$c->error});
+ $c->clear_errors;
+ }
+ $c->stash(
+ title => "Choose the access duration",
+ template => $pf::web::guest::SPONSOR_CHOOSE_ACCESS_DURATION_TEMPLATE,
+ );
+}
+
=head2 doSponsorRegistration
=cut
@@ -175,9 +191,13 @@ sub doSponsorRegistration : Private {
$c->detach('login');
}
if ($values->{$Actions::CHOOSE_ACCESS_DURATION}) {
- my @options_duration = map { { value => $_, label => $_ } } split(',', $values->{$Actions::CHOOSE_ACCESS_DURATION});
- $c->stash->{choose_access_duration} = \@options_duration;
- $c->detach('choose_access_duration');
+ if ($request->param("access_duration")) {
+ pf::activation::set_unregdate('sponsor',$activation_record->{'activation_code'}, pf::config::access_duration($request->param("access_duration")));
+ } else {
+ my @options_duration = map { { value => $_, label => $_ } } split(',', $values->{$Actions::CHOOSE_ACCESS_DURATION});
+ $c->stash->{choose_access_duration} = \@options_duration;
+ $c->detach('choose_access_duration');
+ }
}
}
# handling log out (not exposed to the UI at this point)
@@ -235,22 +255,6 @@ sub doSponsorRegistration : Private {
}
}
-=head2 choose_access_duration
-
-=cut
-
-sub choose_access_duration : Private {
- my ( $self, $c ) = @_;
- if ( $c->has_errors ) {
- $c->stash->{txt_auth_error} = join(' ', grep { ref ($_) eq '' } @{$c->error});
- $c->clear_errors;
- }
- $c->stash(
- title => "Choose the access duration",
- template => $pf::web::guest::SPONSOR_CHOOSE_ACCESS_DURATION_TEMPLATE,
- );
-}
-
=head1 AUTHOR
Inverse inc.
diff --git a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication.pm b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication.pm
index 7ec0f4c84b95..283d642cd728 100644
--- a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication.pm
+++ b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication.pm
@@ -42,7 +42,7 @@ has 'with_aup' => ('is' => 'rw', default => sub {1});
has 'aup_template' => (is => 'rw', default => sub {'aup_text.html'});
-has '+actions' => (default => sub {{"on_success" => [], "on_failure" => [], "destination_url" => [], "role_from_source" => [], "unregdate_from_source" => [], "time_balance_from_source" => [], "bandwidth_balance_from_source" => []}});
+has '+actions' => (default => sub {{"on_success" => [], "on_failure" => [], "destination_url" => [], "role_from_source" => [], "unregdate_from_source" => [], "time_balance_from_source" => [], "bandwidth_balance_from_source" => [], "unregdate_from_sponsor_source" => []}});
has 'signup_template' => ('is' => 'rw', default => sub {'signin.html'});
@@ -68,6 +68,7 @@ sub available_actions {
'bandwidth_balance_from_source',
'on_failure',
'on_success',
+ 'unregdate_from_sponsor_source',
];
}
diff --git a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Sponsor.pm b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Sponsor.pm
index ab56e701f794..8823af2f5f0e 100644
--- a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Sponsor.pm
+++ b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Sponsor.pm
@@ -130,6 +130,7 @@ sub check_activation {
if($record->{status} eq "verified"){
get_logger->info("Activation record has been validated.");
$self->session->{sponsor_activated} = $TRUE;
+ $self->session->{unregdate} = $record->{'unregdate'};
$self->app->response_code(200);
$self->app->template_output('');
}