Re: How to allow and deny different actions based on user's role

2010-08-08 Thread Mariaczi.PL
The pro solution of this problem is ACL.. se this in cookbook and
here:
http://www.mark-story.com/posts/view/auth-and-acl-an-end-to-end-tutorial-pt-1

On 7 Sie, 17:42, Mariano C. mariano.calan...@gmail.com wrote:
 Nothing change...

 On 7 Ago, 17:34, cricket zijn.digi...@gmail.com wrote:







  On Sat, Aug 7, 2010 at 11:19 AM, Mariano C. mariano.calan...@gmail.com 
  wrote:
   I have:
   class AppController extends Controller {
          var $components = array('Auth');

          function beforeFilter() {
          $this-Auth-allow(array('users' = 'register'));

          if ($this-Auth-user('User.role') == 0)
          {
              $this-Auth-deny('*');
              $this-Auth-allow(array('books' = 'index'));
          }
          else
          {
                  $this-Auth-deny('*');
          }
      }
   }

  I believe it should be $this-Auth-user('role')

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to allow and deny different actions based on user's role

2010-08-07 Thread Mariano C.
I have:
class AppController extends Controller {
var $components = array('Auth');

function beforeFilter() {
$this-Auth-allow(array('users' = 'register'));

if ($this-Auth-user('User.role') == 0)
{
$this-Auth-deny('*');
$this-Auth-allow(array('books' = 'index'));
}
else
{
$this-Auth-deny('*');
}
}
}

Now even if user's role is 0, even if user's role is 0 different I'm
allowed everywhere on my site (no action denied).
Ideas?

On 6 Ago, 22:18, Dan Heberden danheber...@gmail.com wrote:
 Just get the role and apply it?

 if( $this-Auth-user('User.role')  1 )  {   // is admin
    $this-Auth-allow( array('secretController' =
 'superSecureAction' ) );

 }

 On Aug 6, 1:12 pm, Mariano C. mariano.calan...@gmail.com wrote:



  I have users table, with field id, username, password and role.
  role is a numeric value: 0 banned users, 1 registered users, 2 admins.

  I've coded AppController like:
  class AppController extends Controller {
          var $components = array('Auth');

          function beforeFilter()
          {
                  $this-Auth-allow(array('users' = 'register'));
          }

  }

  So every user can reach registration page.
  Now I would that for user with different role will be allowed
  different action. How can I handle this just inside the AppController?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to allow and deny different actions based on user's role

2010-08-07 Thread cricket
On Sat, Aug 7, 2010 at 11:19 AM, Mariano C. mariano.calan...@gmail.com wrote:
 I have:
 class AppController extends Controller {
        var $components = array('Auth');

        function beforeFilter() {
        $this-Auth-allow(array('users' = 'register'));

        if ($this-Auth-user('User.role') == 0)
        {
            $this-Auth-deny('*');
            $this-Auth-allow(array('books' = 'index'));
        }
        else
        {
                $this-Auth-deny('*');
        }
    }
 }

I believe it should be $this-Auth-user('role')

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to allow and deny different actions based on user's role

2010-08-07 Thread Mariano C.
Nothing change...

On 7 Ago, 17:34, cricket zijn.digi...@gmail.com wrote:
 On Sat, Aug 7, 2010 at 11:19 AM, Mariano C. mariano.calan...@gmail.com 
 wrote:
  I have:
  class AppController extends Controller {
         var $components = array('Auth');

         function beforeFilter() {
         $this-Auth-allow(array('users' = 'register'));

         if ($this-Auth-user('User.role') == 0)
         {
             $this-Auth-deny('*');
             $this-Auth-allow(array('books' = 'index'));
         }
         else
         {
                 $this-Auth-deny('*');
         }
     }
  }

 I believe it should be $this-Auth-user('role')

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


How to allow and deny different actions based on user's role

2010-08-06 Thread Mariano C.
I have users table, with field id, username, password and role.
role is a numeric value: 0 banned users, 1 registered users, 2 admins.

I've coded AppController like:
class AppController extends Controller {
var $components = array('Auth');

function beforeFilter()
{
$this-Auth-allow(array('users' = 'register'));
}
}

So every user can reach registration page.
Now I would that for user with different role will be allowed
different action. How can I handle this just inside the AppController?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to allow and deny different actions based on user's role

2010-08-06 Thread Dan Heberden
Just get the role and apply it?

if( $this-Auth-user('User.role')  1 )  {   // is admin
   $this-Auth-allow( array('secretController' =
'superSecureAction' ) );
}

On Aug 6, 1:12 pm, Mariano C. mariano.calan...@gmail.com wrote:
 I have users table, with field id, username, password and role.
 role is a numeric value: 0 banned users, 1 registered users, 2 admins.

 I've coded AppController like:
 class AppController extends Controller {
         var $components = array('Auth');

         function beforeFilter()
         {
                 $this-Auth-allow(array('users' = 'register'));
         }

 }

 So every user can reach registration page.
 Now I would that for user with different role will be allowed
 different action. How can I handle this just inside the AppController?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en