/[SQLSession]/trunk/lib/SQLSession/CurrentUser.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/SQLSession/CurrentUser.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 45 by dpavlin, Sun Jan 21 12:19:58 2007 UTC revision 47 by dpavlin, Sun Jan 21 12:41:35 2007 UTC
# Line 20  sub _init { Line 20  sub _init {
20          $self->SUPER::_init(%args);          $self->SUPER::_init(%args);
21  }  }
22    
23    =head2 role
24    
25    Test if user has role
26    
27      Jifty->web->current_user->role( 'edit' );
28    
29    =cut
30    
31  sub role {  sub role {
32          my $self = shift;          my $self = shift;
33          my $role = shift;          my $role = shift;
34    
35          return 0 unless ($self->current_user->id);          return 0 unless ($self->current_user->id);
36    
37          warn "role is '$role' for ", $self->current_user->user_object->email, "?";          my $r = SQLSession::Model::Role->new();
38            $r->load_by_cols(
39                    user_id => $self->current_user->id,
40                    role => $role
41            );
42    
43            warn "role is '$role' for ", $self->current_user->user_object->email, " ",
44                    $r->id ? 'OK' : 'DENY', $/;
45    
46          return 1 if ($self->current_user->user_object->email eq 'dpavlin@rot13.org');          return $r->id;
47    
48          return 0;          return 0;
49  }  }

Legend:
Removed from v.45  
changed lines
  Added in v.47

  ViewVC Help
Powered by ViewVC 1.1.26