Preparing auth setup to support per-method reset/activation support.

This commit is contained in:
Chris 2013-01-08 21:20:23 +00:00
parent 9e883ced44
commit 4b646cc3d4

View File

@ -35,6 +35,7 @@ use HTML::Entities;
# Custom module imports
use Webperl::AuthMethods;
use Webperl::AuthMethod;
# ============================================================================
# Constructor
@ -273,4 +274,26 @@ sub valid_user {
return $self -> self_error("Invalid username or password specified.");
}
## @method $ get_user_authmethod_module($username)
# Given a username, obtain a reference to an AuthMethod implementation for the user's
# authmethod. If the user has no authmethod set, this will return a reference to an
# object of the base AuthMethod class rather than a fully-featured subclass.
#
# @param username The username of the user to obtain the AuthMethod for.
# @return A reference to the user's AuthMethod object on success, undef on error.
sub get_user_authmethod_module {
my $self = shift;
my $username = shift;
# Does the user have an authmethod set?
my $authmethod = $self -> {"app"} -> get_user_authmethod($username);
return $self -> {"methods"} -> load_method($authmethod)
if($authmethod);
# If the user doesn't have an AuthMethod set, fall back on the base class.
return AuthMethod -> new();
}
1;