From 4af7c25fd0481700cde8d0e7c359ae9ebbdd50f9 Mon Sep 17 00:00:00 2001 From: James Rouzier Date: Mon, 16 Dec 2024 12:10:39 +0000 Subject: [PATCH 1/3] Use source from profile if none is set in Module. --- .../DynamicRouting/Module/Authentication.pm | 6 +++--- .../DynamicRouting/Module/Authentication/SMS.pm | 11 ++++++++++- .../DynamicRouting/Module/Authentication/Sponsor.pm | 11 ++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) 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 f5cd419e2c9c..f4cffbe0e10d 100644 --- a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication.pm +++ b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication.pm @@ -29,7 +29,7 @@ use pf::constants::role qw($REJECT_ROLE); has 'source' => (is => 'rw', isa => 'pf::Authentication::Source|Undef'); -has 'source_id' => (is => 'rw', trigger => \&_build_source); +has 'source_id' => (is => 'rw', trigger => \&_rebuild_source); has 'required_fields' => (is => 'rw', isa => 'ArrayRef[Str]', builder => '_build_required_fields', lazy => 1); @@ -129,13 +129,13 @@ sub _build_request_fields { return \%request_fields; } -=head2 _build_source +=head2 _rebuild_source Builder for the source using the source_id attribute =cut -sub _build_source { +sub _rebuild_source { my ($self) = @_; $self->source(pf::authentication::getAuthenticationSource($self->{source_id})); } diff --git a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/SMS.pm b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/SMS.pm index 61ef09b8bd64..f07db5868d7a 100644 --- a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/SMS.pm +++ b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/SMS.pm @@ -24,7 +24,11 @@ use pf::auth_log; has '+pid_field' => (default => sub { "telephone" }); -has '+source' => (isa => 'pf::Authentication::Source::SMSSource|pf::Authentication::Source::TwilioSource|pf::Authentication::Source::ClickatellSource'); +has '+source' => ( + isa => 'pf::Authentication::Source::SMSSource|pf::Authentication::Source::TwilioSource|pf::Authentication::Source::ClickatellSource', + lazy => 1, + builder => '_build_source', +); =head2 allowed_urls_auth_module @@ -328,6 +332,11 @@ sub auth_source_params_child { }; } +sub _build_source { + my ($self) = @_; + return $self->app->profile->getSourceByType('SMS'); +} + =head1 AUTHOR Inverse inc. 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 1fe11b719763..7cbc1f90a4be 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 @@ -29,7 +29,11 @@ use captiveportal::Base::Actions; use pf::nodecategory; use pf::util; -has '+source' => (isa => 'pf::Authentication::Source::SponsorEmailSource'); +has '+source' => ( + isa => 'pf::Authentication::Source::SponsorEmailSource', + lazy => 1, + builder => '_build_source', +); has 'forced_sponsor' => ('is' => 'rw'); @@ -313,6 +317,11 @@ sub auth_source_params_child { }; } +sub _build_source { + my ($self) = @_; + return $self->app->profile->getSourceByType('Sponsor'); +} + =head1 AUTHOR Inverse inc. From 4e7cd6744e64255d687e330f5d5da5e1924bd596 Mon Sep 17 00:00:00 2001 From: James Rouzier Date: Tue, 17 Dec 2024 18:10:35 +0000 Subject: [PATCH 2/3] use the correct type --- .../PacketFence/DynamicRouting/Module/Authentication/Sponsor.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7cbc1f90a4be..2da80a52caf6 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 @@ -319,7 +319,7 @@ sub auth_source_params_child { sub _build_source { my ($self) = @_; - return $self->app->profile->getSourceByType('Sponsor'); + return $self->app->profile->getSourceByType('SponsorEmail'); } =head1 AUTHOR From cac6fa4a4a32528a144f03aa7ede167632161cfe Mon Sep 17 00:00:00 2001 From: James Rouzier Date: Tue, 17 Dec 2024 19:38:52 +0000 Subject: [PATCH 3/3] Get Email source from profile if not defined --- .../DynamicRouting/Module/Authentication/Email.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Email.pm b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Email.pm index 4e1f74b0fd93..d632933b7411 100644 --- a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Email.pm +++ b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Email.pm @@ -14,7 +14,11 @@ use Moose; extends 'captiveportal::DynamicRouting::Module::Authentication'; with 'captiveportal::Role::FieldValidation'; -has '+source' => (isa => 'pf::Authentication::Source::EmailSource'); +has '+source' => ( + isa => 'pf::Authentication::Source::EmailSource', + lazy => 1, + builder => '_build_source', +); use pf::auth_log; use pf::config qw(%Config); @@ -171,6 +175,11 @@ sub auth_source_params_child { }; } +sub _build_source { + my ($self) = @_; + return $self->app->profile->getSourceByType('Email'); +} + =head1 AUTHOR Inverse inc.