return $self->client;
}
+sub get_default_client_id {
+ my ($self) = @_;
+
+ my $dbh = $self->dbconnect;
+
+ return unless $dbh;
+
+ my $row = $dbh->selectrow_hashref(qq|SELECT id FROM auth.clients WHERE is_default = TRUE LIMIT 1|);
+
+ return $row->{id} if $row;
+}
+
sub DESTROY {
my $self = shift;
# 1. session ID exists in the database
# 2. hasn't expired yet
# 3. if cookie for the API token is given: the cookie's value equal database column 'auth.session.api_token' for the session ID
- # 4. if cookie for the API token is NOT given then: the requestee's IP address must match the stored IP address
$self->{api_token} = $cookie->{api_token} if $cookie;
my $api_token_cookie = $self->get_api_token_cookie;
my $cookie_is_bad = !$cookie || $cookie->{is_expired};
$cookie_is_bad ||= $api_token_cookie && ($api_token_cookie ne $cookie->{api_token}) if $api_token_cookie;
- $cookie_is_bad ||= $cookie->{ip_address} ne $ENV{REMOTE_ADDR} if !$api_token_cookie && $ENV{REMOTE_ADDR} !~ /^$IPv6_re$/;
if ($cookie_is_bad) {
$self->destroy_session();
return $self->session_restore_result($cookie ? SESSION_EXPIRED() : SESSION_NONE());
my $value = 0;
my $action = '|';
+ my $negate = 0;
foreach my $el (@{$ary}) {
if (ref $el eq "ARRAY") {
+ my $val = evaluate_rights_ary($el);
+ $val = !$val if $negate;
+ $negate = 0;
if ($action eq '|') {
- $value |= evaluate_rights_ary($el);
+ $value |= $val;
} else {
- $value &= evaluate_rights_ary($el);
+ $value &= $val;
}
} elsif (($el eq '&') || ($el eq '|')) {
$action = $el;
+ } elsif ($el eq '!') {
+ $negate = !$negate;
+
} elsif ($action eq '|') {
- $value |= $el;
+ my $val = $el;
+ $val = !$val if $negate;
+ $negate = 0;
+ $value |= $val;
} else {
- $value &= $el;
+ my $val = $el;
+ $val = !$val if $negate;
+ $negate = 0;
+ $value &= $val;
}
}
Creating a new database handle on each request can take up to 30% of the
pre-request startup time, so we want to avoid that for fast ajax calls.
+=item C<assert, $right, $dont_abort>
+
+Checks if current user has the C<$right>. If C<$dont_abort> is falsish
+the request dies with a access denied error, otherwise returns true or false.
+
=back
=head1 BUGS