AppController:
function isAuthorized()
{
if (isset($this->params['prefix']) && $this->params['prefix'] ==
Configure::read('Routing.admin'))
{
if ($this->Auth->user('model') ! = 'Administrator')
{
return false;
}
}
return true;
}
This is from a 1.3.x site.
On Thu, Aug 30, 2012 at 8:20 PM, Advantage+ <movepixels@gmail.com> wrote:
> Sorry sounded good, but than what about me when I want to login as admin?
> I need admin role so I guess I cannot simply drop roles.
>
> -----Original Message-----
> From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
> Of lowpass
> Sent: Thursday, August 30, 2012 9:10 PM
> To: cake-php@googlegroups.com
> Subject: Re: Database Setup Help / Relations
>
> That's what I've done in the past. Although I didn't use a Role model.
>
> User:
>
> public $hasOne = array(
> 'Member' => array(
> 'className' => 'Member',
> 'foreignKey' => 'user_id',
> 'dependent' => true
> ),
> 'Affiliate' => array(
> 'className' => 'Affiliate',
> 'foreignKey' => 'user_id',
> 'dependent' => true
> ),
> 'Administrator' => array(
> 'className' => 'Administrator',
> 'foreignKey' => 'user_id',
> 'dependent' => true
> )
> );
>
> Member:
>
> public $belongsTo = array(
> 'User' => array(
> 'className' => 'User',
> 'foreignKey' => 'user_id'
> )
> );
>
> In the users table there are columns for model and foreign_key. In the login
> action I grab the data from the associated model:
>
> $model_name = $this->Auth->user('model');
> $this->User->{$model_name}->recursive = -1; $data =
> $this->User->{$model_name}->read(
> null,
> $this->Auth->user('foreign_key')
> );
>
> $this->Session->write(
> $model_name,
> $data[$model_name]
> );
>
> On Thu, Aug 30, 2012 at 5:27 PM, Advantage+ <movepixels@gmail.com> wrote:
>> I need to build a dual sided / role related site so there are 2 types
>> of Users (Buyer and Seller) so upon registration User will select who
>> they are and based on that create the User.
>>
>> They can only be one or the other.
>>
>> So when logged in as Buyer the can access the buyer end of the site,
>> same as Seller.
>>
>>
>>
>> But the issues I see come because the Seller / Buyer have different
>> relations to other models. Is it better off to create the Buyer /
>> Seller as separate MVC objects?
>>
>>
>>
>> Something like this for User model?
>>
>>
>>
>> public $belongsTo = array(
>>
>> 'Role' => array(
>>
>> 'className' => 'Role',
>>
>> 'foreignKey' =>
>> 'role_id',
>>
>> 'conditions' => '',
>>
>> 'fields' => '',
>>
>> 'order' => ''
>>
>> )
>>
>> );
>>
>>
>>
>> public $hasOne = array(
>>
>> 'Buyer' => array(
>>
>> 'className' =>
>> 'Buyer',
>>
>> 'foreignKey' =>
>> 'user_id',
>>
>> ),
>>
>> 'Seller' => array(
>>
>> 'className' =>
>> 'Seller',
>>
>> 'foreignKey' =>
>> 'user_id',
>>
>> )
>>
>> );
>>
>>
>>
>>
>>
>> Open to the hearing best solution to this issue from the community.
>>
>>
>>
>> Thanks.
>>
>> --
>> 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+unsubscribe@googlegroups.com.
>> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>>
>>
>
> --
> 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+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>
>
> --
> 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+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>
--
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
Friday, August 31, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment