Hello Bum,
Thanks! So did this fix the issue?
If so - do you know if these changes are being rolled into the next release
of the PF?
Cheers,
Boris.
On Tue, Jun 17, 2014 at 12:07 AM, Bun Him Dara <[email protected]> wrote:
> Thanks all for you response.
>
> After fiddling with it a bit following are fixed that I have made.
>
> First: 4.2.2 seem to have lot of problem in it from the sponsor function
> side.
> - getDestinationUrl does not exist
> - ::cgi object used in the Session.pm through me error (could be because i
> have upgrade some object from the developer dependency package)
>
> So I decide to test out the 4.3, and following are fix I have made to
> correct the function:
> - getDestinationUrl still use in the CaptivePortal.pm: I create this
> function in the Session.pm with following code
> sub getDestinationUrl {
> my ($self) = @_;
> return $self->_build_destinationUrl;
> }
>
> - the other problem is in the Activation/email.pm
> function doSponsorRegistration I am not sure if those if clause are
> intended or just incorrectly close so I adjust to the folling to have this
> function work as expected. change is made start from if (
> defined($node_mac) )
>
>
> sub doSponsorRegistration : Private {
> my ( $self, $c, $code ) = @_;
> my $logger = get_logger;
> my $request = $c->request;
> my $activation_record = $c->stash->{activation_record};
> my $portalSession = $c->portalSession;
> my $node_mac = $portalSession->guestNodeMac;
> my ( $pid, $email ) = @{$activation_record}{ 'pid', 'email' };
> my $auth_params = {
> 'username' => $pid,
> 'user_email' => $email
> };
>
> my $profile = $c->profile;
> my $sponsor_type =
> pf::Authentication::Source::SponsorEmailSource->getDefaultOfType;
> my $source = $profile->getSourceByType($sponsor_type);
>
> if ($source) {
>
> 248,0-1
> 61%
> if ($source) {
>
> # if we have a username in session it means user has already
> authenticated
> # so we go ahead and allow the guest in
> if ( !defined( $c->session->{"username"} ) ) {
>
> # User is not logged and didn't provide username or password:
> show login form
> if (!( $request->param("username") &&
> $request->param("password")
> )
> ) {
> $logger->info(
> "Sponsor needs to authenticate in order to activate
> guest. Guest token: $code"
> );
> $c->detach('login');
> }
>
> # User provided username and password: authenticate
> $c->forward(Authenticate => 'authenticationLogin');
> $c->detach('login') if $c->has_errors;
>
> 247,5
> 67%
> $c->detach('login') if $c->has_errors;
>
> }
>
> # handling log out (not exposed to the UI at this point)
> # TODO: if we ever expose it, we'll need to alter the form action
> to make sure to trim it
> # otherwise we'll submit our authentication but with
> ?action=logout so it'll delete the session right away
> if ( defined( $request->param("action") )
> && $request->param("action") eq "logout" ) {
> $c->session->{username} = undef;
> $c->detach('login');
> }
>
> # User is authenticated (session username exists OR auth_return ==
> $TRUE above)
> $logger->debug( $c->session->{username}
> . " successfully authenticated. Activating sponsored guest"
> );
>
> my ( %info, $template );
>
> if ( defined($node_mac) ) {
> 265,13
> 71%
>
> if ( defined($node_mac) ) {
>
> # If MAC is defined, it's a guest already here that we need to
> register
> my $node_info = node_attributes($node_mac);
> $pid = $node_info->{'pid'};
> if ( !defined($node_info) || ref($node_info) ne 'HASH' ) {
>
> $logger->warn(
> "Problem finding more information about a MAC address
> ($node_mac) to enable guest access"
> );
> $self->showError(
> "There was a problem trying to find the computer to
> register. The problem has been logged."
> );
> }
>
> if ( $node_info->{'status'} eq $pf::node::STATUS_REGISTERED )
> {
>
> $logger->warn(
> 283,0-1
> 76%
>
> $logger->warn(
> "node mac: $node_mac has already been registered.");
> $self->showError(
> "The device with MAC address %s has already been
> authorized to your network.",
> $node_mac
> );
> }
>
> # register the node
> %info = %{$node_info};
> $c->forward( 'CaptivePortal' => 'webNodeRegister', [ $pid,
> %info ] );
>
> # populating variables used to send email
> $template =
> $pf::web::guest::TEMPLATE_EMAIL_GUEST_ON_REGISTRATION;
> $info{'subject'} = i18n_format(
> "%s: Guest network access enabled",
> $Config{'general'}{'domain'}
> );
>
> 301,0-1
> 81%
> );
>
> }
> elsif ( defined( $activation_record->{'pid'} ) ) {
>
> # If pid is set in activation record then we are activating a
> guest who pre-registered
>
> $pid = $activation_record->{'pid'};
>
> # populating variables used to send email
> $template =
> $pf::web::guest::TEMPLATE_EMAIL_SPONSOR_PREREGISTRATION;
> $info{'subject'} = i18n_format(
> "%s: Guest access request accepted",
> $Config{'general'}{'domain'}
> );
> }
>
> # TO:
> $info{'email'} = $pid;
>
> # username
> 319,13
> 87%
>
> # username
> $info{'pid'} = $pid;
> $info{'cc'} =
> $Config{'guests_self_registration'}{'sponsorship_cc'};
>
> # we create a temporary password using the actions from the
> sponsor authentication source;
> # NOTE: When sponsoring a network access, the new user will be
> created (in the temporary_password table) using
> # the actions of the sponsor authentication source of the portal
> profile on which the *sponsor* has landed.
> my $actions = &pf::authentication::match( $source->{id},
> { username => $pid, user_email => $pid } );
> $info{'password'} =
> pf::temporary_password::generate( $pid, $actions );
>
> # prepare welcome email for a guest who registered locally
> $info{'currentdate'} =
> POSIX::strftime( "%m/%d/%y %H:%M:%S", localtime );
>
> pf::web::guest::send_template_email( $template, $info{'subject'},
> \%info );
> 339,0-1
> 92%
> pf::web::guest::send_template_email( $template, $info{'subject'},
> \%info );
> pf::email_activation::set_status_verified($code);
>
> # send to a success page
> $c->stash(
> template => $pf::web::guest::SPONSOR_CONFIRMED_TEMPLATE );
> $c->detach;
> } else {
> $logger->warn( "No active sponsor source for profile "
> . $profile->getName
> . ", redirecting to "
> . $Config{'trapping'}{'redirecturl'} );
> $c->response->redirect( $Config{'trapping'}{'redirecturl'} );
> }
> }
>
>
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems
> _______________________________________________
> PacketFence-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/packetfence-users
>
>
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
PacketFence-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/packetfence-users