Hi Matthew,
i think you always dream to be a beta tester for packetfence so here a
patch for Sponsor with the file1 source.
I order to make it work, in user tab select admin and set an email
address (Sponsor mail) in file1 in the admins rule add mark as sponsor.
Then apply the following patch.
If it work, it will be in the 4.0.2 version of packetfence.
diff --git a/lib/pf/Authentication/Source/SQLSource.pm
b/lib/pf/Authentication/Source/SQLSource.pm
index 63185d7..ce732d3 100644
--- a/lib/pf/Authentication/Source/SQLSource.pm
+++ b/lib/pf/Authentication/Source/SQLSource.pm
@@ -115,6 +115,19 @@ sub match {
return undef;
}
+=head2 username_from_email
+
+=cut
+
+sub username_from_email {
+ my ( $self, $email ) = @_;
+
+ my $logger = Log::Log4perl->get_logger('pf::authentication');
+
+ return pf::temporary_password::match_by_mail($email);
+
+}
+
=head1 AUTHOR
Inverse inc. <[email protected]>
diff --git a/lib/pf/authentication.pm b/lib/pf/authentication.pm
index e8d9709..2d51633 100644
--- a/lib/pf/authentication.pm
+++ b/lib/pf/authentication.pm
@@ -409,7 +409,8 @@ sub username_from_email {
my $classname = $source->meta->name;
if ($classname eq 'pf::Authentication::Source::ADSource' ||
- $classname eq 'pf::Authentication::Source::LDAPSource') {
+ $classname eq 'pf::Authentication::Source::LDAPSource' ||
+ $classname eq 'pf::Authentication::Source::SQLSource' ) {
my $username = $source->username_from_email($email);
diff --git a/lib/pf/temporary_password.pm b/lib/pf/temporary_password.pm
index f92c096..8c4bdca 100644
--- a/lib/pf/temporary_password.pm
+++ b/lib/pf/temporary_password.pm
@@ -69,7 +69,7 @@ BEGIN {
@EXPORT_OK = qw(
view add modify
- create
+ create match_by_mail
validate_password
$AUTH_SUCCESS $AUTH_FAILED_INVALID $AUTH_FAILED_EXPIRED
$AUTH_FAILED_NOT_YET_VALID
);
@@ -140,6 +140,12 @@ sub temporary_password_db_prepare {
UPDATE temporary_password SET password = ? WHERE pid = ?
]);
+
$temporary_password_statements->{'temporary_password_match_by_mail_sql'}
= get_db_handle()->prepare(qq[
+ SELECT pid
+ FROM temporary_password
+ WHERE mail = ?
+ ]);
+
$temporary_password_db_prepared = 1;
}
@@ -445,6 +451,28 @@ sub reset_password {
) || return;
}
+=item match_by_mail
+
+Return the username
+
+=cut
+
+sub match_by_mail {
+ my ($mail) = @_;
+ my $query = db_query_execute(
+ TEMPORARY_PASSWORD, $temporary_password_statements,
'temporary_password_match_by_mail_sql', $mail
+ ) || return;
+ my $ref = $query->fetchrow_hashref();
+
+ # just get one row and finish
+ $query->finish();
+ if (defined($ref)) {
+ return ($ref);
+ } else {
+ return undef;
+ }
+}
+
=back
Regards
Fabrice
Le 2013-06-20 08:49, matthew vassallo a écrit :
Hi Fabrice,
Kindly can you explain how do I need to do that exactly please? I have
to add a local sponsor (no AD or that). I went to sources and there is
Htpasswd file which is pointing too admin.conf (this does not exist in
/usrl/local/pf/conf and had to add it myself). When I added a rule
there and marked the user as sponsor, it sill did not work. All other
sources do not make sense. I also tried adding a rule in email source
but still did not work.
------------------------------------------------------------------------
Date: Thu, 20 Jun 2013 08:23:57 -0400
From: [email protected]
To: [email protected]
Subject: Re: [PacketFence-users] Email <e-mail> is not allowed to
sponsor guest access
Hello Matthew,
in source you have to set a sponsor in the rule.
Regards
Fabrice
Le 2013-06-20 03:10, matthew vassallo a écrit :
Hi,
I am having a problem in adding a sponsor in PF. When the client
clicks on Register via a Sponsor, he gets the following message -
"Email <e-mail> is not allowed to sponsor guest access". In the
previous version I had to add user.conf file in
/usr/local/pf/conf/ path and add the required sponsor there. In
this version such method does not work. Kindly can you explain
what I need to do please? Thanks
Regards,
Matthew
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
PacketFence-users mailing list
[email protected]
<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/packetfence-users
--
Fabrice Durand
[email protected] <mailto:[email protected]> :: +1.514.447.4918 (x135)
::www.inverse.ca <http://www.inverse.ca>
Inverse inc. :: Leaders behind SOGo (http://www.sogo.nu) and PacketFence
(http://packetfence.org)
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows: Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________ PacketFence-users
mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/packetfence-users
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
PacketFence-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/packetfence-users
--
Fabrice Durand
[email protected] :: +1.514.447.4918 (x135) :: www.inverse.ca
Inverse inc. :: Leaders behind SOGo (http://www.sogo.nu) and PacketFence
(http://packetfence.org)
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
PacketFence-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/packetfence-users