Skip to content

Commit

Permalink
add multiple auth methods and www_ methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Bell committed Jun 22, 2010
1 parent 9ddc60b commit b663108
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/WebGUI/Auth.pm
Expand Up @@ -809,7 +809,9 @@ Returns whether or not a method is callable

sub isCallable {
my $self = shift;
return isIn($_[0],@{$self->{callable}})
return 1 if isIn($_[0],@{$self->{callable}});
return 1 if $self->can( 'www_' . $_[0] );
return 0;
}

#-------------------------------------------------------------------
Expand Down
20 changes: 16 additions & 4 deletions lib/WebGUI/Operation/Auth.pm
Expand Up @@ -14,6 +14,7 @@ package WebGUI::Operation::Auth;
# logic that defines how Authentication should happen

use strict qw(vars subs);
use List::MoreUtils qw( any );
use URI;
use WebGUI::Operation::Shared;
use WebGUI::Pluggable;
Expand All @@ -33,9 +34,16 @@ Get the instance of this object or create a new instance if none exists
sub getInstance {
my $session = shift;
#Get Auth Settings
my $authMethod = $session->user->authMethod || $session->setting->get("authMethod");
$authMethod = $session->setting->get("authMethod") if($session->user->isVisitor);
$authMethod = $_[0] if($_[0] && isIn($_[0], @{$session->config->get("authMethods")}));
my $authMethod = $_[0]
|| ( !$session->user->isVisitor && $session->user->authMethod ) # Visitor has no authType
|| $session->form->get('authType')
|| $session->setting->get("authMethod")
;
# Verify is in auth method list
if ( !any { $_ eq $authMethod } @{$session->config->get('authMethods')} ) {
$authMethod = $session->setting->get('authMethod');
}

my $userId = $_[1];
#Create Auth Object
my $auth = eval { WebGUI::Pluggable::instanciate("WebGUI::Auth::".$authMethod, "new", [ $session, $authMethod, $userId ] ) };
Expand Down Expand Up @@ -72,7 +80,11 @@ sub www_auth {
my $i18n = WebGUI::International->new($session);
return $i18n->get(1077);
}
my $out = $authMethod->$methodCall;

# Determine if we have a www_ method
my $method = $authMethod->can( 'www_' . $methodCall )
|| $authMethod->can( $methodCall );
my $out = $method->( $authMethod );
if (substr($session->http->getMimeType(),0,9) eq "text/html") {
return $session->style->userStyle($out);
}
Expand Down

0 comments on commit b663108

Please sign in to comment.