1 package SL::Dispatcher::AuthHandler;
5 use parent qw(Rose::Object);
7 use SL::Dispatcher::AuthHandler::Admin;
8 use SL::Dispatcher::AuthHandler::None;
9 use SL::Dispatcher::AuthHandler::User;
11 my %valid_auth_levels = map { ($_ => 1) } qw(user admin none);
14 my ($self, %param) = @_;
16 my $auth_level = $self->get_auth_level(%param);
17 my $handler_name = "SL::Dispatcher::AuthHandler::" . ucfirst($auth_level);
18 $self->{handlers} ||= {};
19 $self->{handlers}->{$handler_name} ||= $handler_name->new;
20 $self->{handlers}->{$handler_name}->handle;
23 auth_level => $auth_level,
24 keep_auth_vars => $self->get_keep_auth_vars(%param),
29 my ($self, %param) = @_;
31 my $auth_level = $param{routing_type} eq 'old' ? ($param{script} eq 'admin' ? 'admin' : 'user')
32 : $param{routing_type} eq 'controller' ? "SL::Controller::$param{controller}"->get_auth_level($param{action})
35 return $valid_auth_levels{$auth_level} ? $auth_level : 'user';
38 sub get_keep_auth_vars {
39 my ($self, %param) = @_;
41 return $param{routing_type} eq 'controller' ? "SL::Controller::$param{controller}"->keep_auth_vars_in_form : 0;