Quantcast

Using Auth To Limit Results

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using Auth To Limit Results

elogic
Is there any quick / better way to use Auth to limit the results based
on the users login details or is it just a matter of using if/else
statments to get what you want.

For example, I have a list of products which all have a group id
assigned to them. Each user also has a group id. When the user is
logged in they are to only show the products that matches their group
id.

I'm only new to cakephp and still do not know all the tricks or short
cuts for things like this.

Thankyou

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Auth To Limit Results

Teddy Zeenny
I guess you can do something like this:

$group_id=$this->Auth->user('group_id');

$products=$this->Product->find('all',array('conditions'=>array('Product.group_id'=>$group_id)));

Is this what you're looking for ?

Teddy


On Wed, Sep 21, 2011 at 12:28 PM, elogic <[hidden email]> wrote:
Is there any quick / better way to use Auth to limit the results based
on the users login details or is it just a matter of using if/else
statments to get what you want.

For example, I have a list of products which all have a group id
assigned to them. Each user also has a group id. When the user is
logged in they are to only show the products that matches their group
id.

I'm only new to cakephp and still do not know all the tricks or short
cuts for things like this.

Thankyou

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Auth To Limit Results

sathyashrayan
In reply to this post by elogic


On Sep 21, 2:28 pm, elogic <[hidden email]> wrote:

> Is there any quick / better way to use Auth to limit the results based
> on the users login details or is it just a matter of using if/else
> statments to get what you want.
>
> For example, I have a list of products which all have a group id
> assigned to them. Each user also has a group id. When the user is
> logged in they are to only show the products that matches their group
> id.
>
> I'm only new to cakephp and still do not know all the tricks or short
> cuts for things like this.
>
> Thankyou

So we have users table, roles table, products table. users table has a
role_id (FK) and products table also has a role_id (FK). With $this-
>Auth->user() you can get the user details as array. Then check the
product table with the retrieve role_id.

Please note. Use the name roles for role table and role_id as a FK
name. Use cakePhp Auth component for loin sessions.
http://book.cakephp.org/view/1250/Authentication Understand how Auth
is used and implemented. May be you need to use ACL at one stage.

Experts might help more..

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Auth To Limit Results

Thomas Ploch
In reply to this post by elogic
Taking that you are new to CakePHP this might be a bit too hard to
digest, but I recommend at least reading this article:

http://jmcneese.wordpress.com/2009/04/19/rmac-ftw-part-1/
http://jmcneese.wordpress.com/2010/01/28/rmac-is-dead-long-live-rmac/

This is implementing UNIX-style permissions for Model access, which is
basically what you want.

Kind regards
Thomas

Am 21.09.2011 11:28, schrieb elogic:

> Is there any quick / better way to use Auth to limit the results based
> on the users login details or is it just a matter of using if/else
> statments to get what you want.
>
> For example, I have a list of products which all have a group id
> assigned to them. Each user also has a group id. When the user is
> logged in they are to only show the products that matches their group
> id.
>
> I'm only new to cakephp and still do not know all the tricks or short
> cuts for things like this.
>
> Thankyou
>

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Auth To Limit Results

phpMagpie
I don't see why this has to get any more complex than what Teddy
suggested?  I have always stayed well clear of ACL as it was too
complex for me to implement when first learning CakePHP and I've never
needed more than standard Auth and User Groups in the many CakePHP
sites I have developed since.

@Thomas: I have however bookmarked that RMAC plugin for further
reading - maybe I should go back and look at ACL some time too.

HTH, Paul

On Sep 21, 12:05 pm, Thomas Ploch <[hidden email]> wrote:

> Taking that you are new to CakePHP this might be a bit too hard to
> digest, but I recommend at least reading this article:
>
> http://jmcneese.wordpress.com/2009/04/19/rmac-ftw-part-1/http://jmcneese.wordpress.com/2010/01/28/rmac-is-dead-long-live-rmac/
>
> This is implementing UNIX-style permissions for Model access, which is
> basically what you want.
>
> Kind regards
> Thomas
>
> Am 21.09.2011 11:28, schrieb elogic:
>
>
>
>
>
>
>
> > Is there any quick / better way to use Auth to limit the results based
> > on the users login details or is it just a matter of using if/else
> > statments to get what you want.
>
> > For example, I have a list of products which all have a group id
> > assigned to them. Each user also has a group id. When the user is
> > logged in they are to only show the products that matches their group
> > id.
>
> > I'm only new to cakephp and still do not know all the tricks or short
> > cuts for things like this.
>
> > Thankyou

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Auth To Limit Results

elogic
Thanks, I agree. Simple is better at the moment. it seems to cover
everything I want.

Thanks for the replies.

On Sep 22, 5:41 pm, WebbedIT <[hidden email]> wrote:

> I don't see why this has to get any more complex than what Teddy
> suggested?  I have always stayed well clear of ACL as it was too
> complex for me to implement when first learning CakePHP and I've never
> needed more than standard Auth and User Groups in the many CakePHP
> sites I have developed since.
>
> @Thomas: I have however bookmarked that RMAC plugin for further
> reading - maybe I should go back and look at ACL some time too.
>
> HTH, Paul
>
> On Sep 21, 12:05 pm, Thomas Ploch <[hidden email]> wrote:
>
>
>
>
>
>
>
> > Taking that you are new to CakePHP this might be a bit too hard to
> > digest, but I recommend at least reading this article:
>
> >http://jmcneese.wordpress.com/2009/04/19/rmac-ftw-part-1/http://jmcne...
>
> > This is implementing UNIX-style permissions for Model access, which is
> > basically what you want.
>
> > Kind regards
> > Thomas
>
> > Am 21.09.2011 11:28, schrieb elogic:
>
> > > Is there any quick / better way to use Auth to limit the results based
> > > on the users login details or is it just a matter of using if/else
> > > statments to get what you want.
>
> > > For example, I have a list of products which all have a group id
> > > assigned to them. Each user also has a group id. When the user is
> > > logged in they are to only show the products that matches their group
> > > id.
>
> > > I'm only new to cakephp and still do not know all the tricks or short
> > > cuts for things like this.
>
> > > Thankyou

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Loading...