Skip to content

Commit

Permalink
Use source from profile if none is set in Module.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouzierinverse committed Dec 16, 2024
1 parent a0a62f1 commit 4af7c25
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 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 @@ -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('Sponsor');
}

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

0 comments on commit 4af7c25

Please sign in to comment.