Skip to content

Commit

Permalink
Merge pull request #8439 from inverse-inc/fix/8392
Browse files Browse the repository at this point in the history
Use source from profile if none is set in Module.
  • Loading branch information
fdurand authored Dec 17, 2024
2 parents bb205dc + cac6fa4 commit 5527328
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -171,6 +175,11 @@ sub auth_source_params_child {
};
}

sub _build_source {
my ($self) = @_;
return $self->app->profile->getSourceByType('Email');
}

=head1 AUTHOR
Inverse inc. <info@inverse.ca>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -328,6 +332,11 @@ sub auth_source_params_child {
};
}

sub _build_source {
my ($self) = @_;
return $self->app->profile->getSourceByType('SMS');
}

=head1 AUTHOR
Inverse inc. <info@inverse.ca>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -313,6 +317,11 @@ sub auth_source_params_child {
};
}

sub _build_source {
my ($self) = @_;
return $self->app->profile->getSourceByType('SponsorEmail');
}

=head1 AUTHOR
Inverse inc. <info@inverse.ca>
Expand Down

0 comments on commit 5527328

Please sign in to comment.