Trevor
Trevor

Reputation: 149

How do I get Yii2 RBAC via DbManager use Joomla "user" table and userid from Joomla session?

I have Joomla running to control the placement of content and to manage user registration/login. Also I have Yii2 running which I integrated by following these instructions: http://www.yiiframework.com/doc-2.0/guide-tutorial-yii-integration.html

I want a user to be able to login through Joomla's login system, and then use Yii2's built-in RBAC support via DbManager (http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#rbac) to verify the logged in user's permissions in the auth_assignment table before running a particular Yii2 function.

I'm not sure what I have to do to tell Yii2 to use the "user" table used by Joomla and also to check this table for the userid when performing RBAC permission checks such as the following example:

if (Yii::$app->user->can('some-auth-item')) 
    { 
        return $this->render('some-page'); 
    }

Upvotes: 2

Views: 127

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

I think this link could be usefule http://www.yiiframework.com/forum/index.php/topic/67481-integrating-yii2-into-joomla-and-using-joomlas-user-table/

Mainly You need change the user table

class User extends ActiveRecord implements IdentityInterface
{

  public static function tableName()
  {
     return 'fm3lk_user';
  }

Upvotes: 1

Related Questions