/[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 58 by dpavlin, Thu Jan 25 13:08:06 2007 UTC revision 88 by dpavlin, Mon Feb 5 18:46:13 2007 UTC
# Line 15  sub _init { Line 15  sub _init {
15          my $self = shift;          my $self = shift;
16          my %args = (@_);          my %args = (@_);
17    
         warn "_init";  
   
18          if ( delete $args{'_bootstrap'} ) {          if ( delete $args{'_bootstrap'} ) {
19                  $self->is_bootstrap_user(1);                  $self->is_bootstrap_user(1);
20          } elsif( keys %args ) {          } elsif( keys %args ) {
# Line 34  sub _init { Line 32  sub _init {
32                          role => 'admin',                          role => 'admin',
33                  );                  );
34                  if ($r->id) {                  if ($r->id) {
35                          warn "turn on AdminMode for ", $self->current_user->user_object->email, $/;                          Jifty->log->debug("turn on AdminMode for ", $self->current_user->user_object->email);
36                          $self->is_superuser(1);                          $self->is_superuser(1);
37                  }                  }
38          }          }
39    
40            # honor AdminMode from config.yml
41            $self->is_superuser(1) if Jifty->config->framework('AdminMode');
42  }  }
43    
44  =head2 role  =head2 role
# Line 56  sub role { Line 57  sub role {
57    
58          return 1 if ($role eq 'admin' && $self->current_user->is_superuser);          return 1 if ($role eq 'admin' && $self->current_user->is_superuser);
59    
60            return 1 if ($role eq 'edit' && $self->current_user->user_object->email_confirmed);
61    
62          my $r = SQLSession::Model::Role->new();          my $r = SQLSession::Model::Role->new();
63          $r->load_by_cols(          $r->load_by_cols(
64                  user_id => $self->current_user->id,                  user_id => $self->current_user->id,
65                  role => $role                  role => $role
66          );          );
67    
68          warn "role is '$role' for ", $self->current_user->user_object->email, " ",          Jifty->log->debug("role is '$role' for ",
69                  $r->id ? 'OK' : 'DENY', $/;                  $self->current_user->user_object->email, " ",
70                    $r->id ? 'OK' : 'DENY'
71            );
72    
73          return $r->id;          return $r->id;
74  }  }
75    
76    1;

Legend:
Removed from v.58  
changed lines
  Added in v.88

  ViewVC Help
Powered by ViewVC 1.1.26