Skip to content

Commit

Permalink
Use the unregistration date provided by the sponsor
Browse files Browse the repository at this point in the history
  • Loading branch information
fdurand committed Jul 16, 2019
1 parent 9d65755 commit 81c368e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions html/captive-portal/lib/captiveportal/Base/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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. <info@inverse.ca>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'});

Expand All @@ -68,6 +68,7 @@ sub available_actions {
'bandwidth_balance_from_source',
'on_failure',
'on_success',
'unregdate_from_sponsor_source',
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
}
Expand Down

0 comments on commit 81c368e

Please sign in to comment.