Note that there are some explanatory texts on larger screens.

plurals
  1. POYii file permission verify doesn't work
    primarykey
    data
    text
    <p>I have a question about yii. <br /></p> <p>I have some videos and the view action is performed based on some privileges. Some videos may be hidden, just for some user categories or for all. I can handle this from yii filter or something, but the real problem is what happen if someone knows the video file path, i can't handle the permissions in this case. </p> <p>My solution is ok, but I have one problem - when someone access direct a file I redirect it (from <code>htaccess</code>) to a page, when I verify the user permission based on it's id. When I try to access the file from url everything is ok, the permission filter works fine, but when I the file is called from the player something it's wrong. From what I saw, the <code>Yii::app()-&gt;user-&gt;id</code> is empty. </p> <p>Any recommendation? </p> <p>This is my <code>UserIdentity</code> class:</p> <pre><code>class UserIdentity extends CUserIdentity { private $_id; /** * Authenticates a user. * @return boolean whether authentication succeeds. */ public function authenticate() { $user=Utilizator::model()-&gt;findByAttributes(array('username'=&gt;$this-&gt;username)); if($user===null) { $this-&gt;errorCode=self::ERROR_USERNAME_INVALID; } else { if($user-&gt;password!==$user-&gt;encrypt($this-&gt;password)) { $this-&gt;errorCode=self::ERROR_PASSWORD_INVALID; } else { $this-&gt;_id = $user-&gt;id; $this-&gt;errorCode=self::ERROR_NONE; } } return !$this-&gt;errorCode; } public function getId() { return $this-&gt;username; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload