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);
18 my $handler_name = "SL::Dispatcher::AuthHandler::" . ucfirst($auth_level);
19 $self->{handlers} ||= {};
20 $self->{handlers}->{$handler_name} ||= $handler_name->new;
21 my $ok = $self->{handlers}->{$handler_name}->handle(%param);
24 auth_level => $auth_level,
25 keep_auth_vars => $self->get_keep_auth_vars(%param),
31 my ($self, %param) = @_;
33 my $auth_level = $param{routing_type} eq 'old' ? ($param{script} eq 'admin' ? 'admin' : 'user')
34 : $param{routing_type} eq 'controller' ? "SL::Controller::$param{controller}"->get_auth_level($param{action})
37 return $valid_auth_levels{$auth_level} ? $auth_level : 'user';
40 sub get_keep_auth_vars {
41 my ($self, %param) = @_;
43 return $param{routing_type} eq 'controller' ? "SL::Controller::$param{controller}"->keep_auth_vars_in_form(action => $param{action}) : 0;