{ my $auth_module; sub _driver { my @auth_modes = split(/\s+/, MT->config->AuthenticationModule); foreach my $auth_mode (@auth_modes) { my $auth_module_name = 'MT::Auth::' . $auth_mode; eval 'require ' . $auth_module_name; if (my $err = $@) { die (MT->translate("Bad AuthenticationModule config '[_1]': [_2]", $auth_mode, $err)); } my $auth_module = $auth_module_name->new; die $auth_module_name->errstr if (!$auth_module || (ref(\$auth_module) eq 'SCALAR')); return $auth_module; } die(MT->translate("Bad AuthenticationModule config")); } sub _handle { my $method = shift; my $mod = $auth_module ||= _driver(); return undef unless $mod->can($method); $mod->$method(@_); } sub release { undef $auth_module; } }