From 4b646cc3d46ae7f5c9dbf49b83e9a91da2ba209f Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 8 Jan 2013 21:20:23 +0000 Subject: [PATCH] Preparing auth setup to support per-method reset/activation support. --- Webperl/Auth.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Webperl/Auth.pm b/Webperl/Auth.pm index dde0afd..5aadc7d 100644 --- a/Webperl/Auth.pm +++ b/Webperl/Auth.pm @@ -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;