add multiple auth methods and www_ methods
This commit is contained in:
parent
b7ba9f2118
commit
68b2c406f7
2 changed files with 19 additions and 5 deletions
|
|
@ -809,7 +809,9 @@ Returns whether or not a method is callable
|
||||||
|
|
||||||
sub isCallable {
|
sub isCallable {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return isIn($_[0],@{$self->{callable}})
|
return 1 if isIn($_[0],@{$self->{callable}});
|
||||||
|
return 1 if $self->can( 'www_' . $_[0] );
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ package WebGUI::Operation::Auth;
|
||||||
# logic that defines how Authentication should happen
|
# logic that defines how Authentication should happen
|
||||||
|
|
||||||
use strict qw(vars subs);
|
use strict qw(vars subs);
|
||||||
|
use List::MoreUtils qw( any );
|
||||||
use URI;
|
use URI;
|
||||||
use WebGUI::Operation::Shared;
|
use WebGUI::Operation::Shared;
|
||||||
use WebGUI::Pluggable;
|
use WebGUI::Pluggable;
|
||||||
|
|
@ -33,9 +34,16 @@ Get the instance of this object or create a new instance if none exists
|
||||||
sub getInstance {
|
sub getInstance {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
#Get Auth Settings
|
#Get Auth Settings
|
||||||
my $authMethod = $session->user->authMethod || $session->setting->get("authMethod");
|
my $authMethod = $_[0]
|
||||||
$authMethod = $session->setting->get("authMethod") if($session->user->isVisitor);
|
|| ( !$session->user->isVisitor && $session->user->authMethod ) # Visitor has no authType
|
||||||
$authMethod = $_[0] if($_[0] && isIn($_[0], @{$session->config->get("authMethods")}));
|
|| $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];
|
my $userId = $_[1];
|
||||||
#Create Auth Object
|
#Create Auth Object
|
||||||
my $auth = eval { WebGUI::Pluggable::instanciate("WebGUI::Auth::".$authMethod, "new", [ $session, $authMethod, $userId ] ) };
|
my $auth = eval { WebGUI::Pluggable::instanciate("WebGUI::Auth::".$authMethod, "new", [ $session, $authMethod, $userId ] ) };
|
||||||
|
|
@ -72,7 +80,11 @@ sub www_auth {
|
||||||
my $i18n = WebGUI::International->new($session);
|
my $i18n = WebGUI::International->new($session);
|
||||||
return $i18n->get(1077);
|
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") {
|
if (substr($session->http->getMimeType(),0,9) eq "text/html") {
|
||||||
return $session->style->userStyle($out);
|
return $session->style->userStyle($out);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue