Commit 58fbd99f authored by Benjamin Rokseth's avatar Benjamin Rokseth
Browse files

koha: add C4::Auth::haspermission override

parent e2894d67
......@@ -121,6 +121,21 @@ sub call {
return "failed";
};
local *{C4::Auth::checkauth} = sub { $session };
local *{C4::Auth::haspermission} = sub {
my ($userid, $perm) = @_;
if (my $auth = $session->param("auth")) {
# TODO: This logic is only satisfy REST Api v1 which checks permissions on its own
if ($perm) {
my ($want) = %{$perm};
my $hit = $auth->{permissions}->{$want};
$hit and return $auth->{permissions};
} else {
# C4::Auth::haspermission called without arguments expects all permissions (!?)
return $auth->{permissions};
}
}
return 0;
};
local *{C4::Context::userenv} = sub { $session->{data} };
# TODO override all context methods?
#local *{C4::Context::set_userenv} = sub { };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment