line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Articulate::Authorisation::OwnerOverride; |
2
|
7
|
|
|
7
|
|
17890
|
use strict; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
274
|
|
3
|
7
|
|
|
7
|
|
34
|
use warnings; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
174
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
694
|
use Moo; |
|
7
|
|
|
|
|
11504
|
|
|
7
|
|
|
|
|
35
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Articulate::Authorisation::OwnerOverride - always say yes to the owner |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 CONFIGURATION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Put this in your config: |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
components: |
18
|
|
|
|
|
|
|
authorisation: |
19
|
|
|
|
|
|
|
Articulate::Authorisation: |
20
|
|
|
|
|
|
|
rules: |
21
|
|
|
|
|
|
|
- Articulate::Authorisation::OwnerOverride |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Or, if you want the owner components: authorisation: |
24
|
|
|
|
|
|
|
Articulate::Authorisation: rules: - class: |
25
|
|
|
|
|
|
|
Articulate::Authorisation::OwnerOverride args: |
26
|
|
|
|
|
|
|
owner: administrator |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head3 owner |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The username of the owner. Defaults to C. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has owner => ( |
37
|
|
|
|
|
|
|
is => 'rw', |
38
|
|
|
|
|
|
|
default => sub { 'owner' } |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head3 new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Yep, C works just as you'd expect. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head3 permitted |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Grants any request if the user asking is the owner. By default this is |
50
|
|
|
|
|
|
|
the user called C, but it could be someone else, if the C |
51
|
|
|
|
|
|
|
attribute is set. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub permitted { |
56
|
6
|
|
|
6
|
1
|
23
|
my $self = shift; |
57
|
6
|
|
|
|
|
13
|
my $permission = shift; |
58
|
6
|
100
|
50
|
|
|
69
|
$permission->grant('Site owner can do anything') |
59
|
|
|
|
|
|
|
if ( ( $permission->user_id // '' ) eq $self->owner ); |
60
|
6
|
|
|
|
|
29
|
return $permission; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |