Your IP : 216.73.216.79


Current Path : /var/www/html/dynawebv3.blunetdev.com/common/components/
Upload File :
Current File : /var/www/html/dynawebv3.blunetdev.com/common/components/AccessRule.php

<?php
 
namespace common\components;

class AccessRule extends \yii\filters\AccessRule
{
    /**
     * @inheritdoc
     */
    protected function matchRole($user)
    {
        if (empty($this->roles)) {
            return true;
        }

        foreach ($this->roles as $role) {
            if ($role === '?') {
                if ($user->getIsGuest()) {
                    return true;
                }
            } elseif ($role === '@') {
                if (!$user->getIsGuest()) {
                    return true;
                }
            // Check if the user is logged in, and the roles match
            } elseif (!$user->getIsGuest() && in_array($role, $user->identity->roles)) {
                return true;
            }
        }
 
        return false;
    }
}