Browse Source

User WIP

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
2fd87fb6d0
  1. 3
      framework/base/Controller.php
  2. 2
      framework/web/HttpCache.php
  3. 55
      framework/web/User.php

3
framework/base/Controller.php

@ -14,9 +14,6 @@ use yii\helpers\StringHelper;
/** /**
* Controller is the base class for classes containing controller logic. * Controller is the base class for classes containing controller logic.
* *
* @property string $route the route (module ID, controller ID and action ID) of the current request.
* @property string $uniqueId the controller ID that is prefixed with the module ID (if any).
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

2
framework/web/HttpCache.php

@ -112,10 +112,8 @@ class HttpCache extends ActionFilter
*/ */
protected function sendCacheControlHeader() protected function sendCacheControlHeader()
{ {
if (Yii::$app->session->isActive) {
session_cache_limiter('public'); session_cache_limiter('public');
header('Pragma:', true); header('Pragma:', true);
}
header('Cache-Control: ' . $this->cacheControl, true); header('Cache-Control: ' . $this->cacheControl, true);
} }

55
framework/web/User.php

@ -223,30 +223,6 @@ class User extends Component
} }
/** /**
* Returns the unique identifier for the user (e.g. username).
* This is the unique identifier that is mainly used for display purpose.
* @return string the user name. If the user is not logged in, this will be {@link guestName}.
*/
public function getName()
{
if (($name = $this->getState('__name')) !== null) {
return $name;
} else {
return $this->guestName;
}
}
/**
* Sets the unique identifier for the user (e.g. username).
* @param string $value the user name.
* @see getName
*/
public function setName($value)
{
$this->setState('__name', $value);
}
/**
* Returns the URL that the user should be redirected to after successful login. * Returns the URL that the user should be redirected to after successful login.
* This property is usually used by the login action. If the login is successful, * This property is usually used by the login action. If the login is successful,
* the action should read this property and use it to redirect the user browser. * the action should read this property and use it to redirect the user browser.
@ -587,7 +563,6 @@ class User extends Component
* Updates the authentication status according to {@link authTimeout}. * Updates the authentication status according to {@link authTimeout}.
* If the user has been inactive for {@link authTimeout} seconds, * If the user has been inactive for {@link authTimeout} seconds,
* he will be automatically logged out. * he will be automatically logged out.
* @since 1.1.7
*/ */
protected function updateAuthStatus() protected function updateAuthStatus()
{ {
@ -600,34 +575,4 @@ class User extends Component
} }
} }
} }
/**
* Performs access check for this user.
* @param string $operation the name of the operation that need access check.
* @param array $params name-value pairs that would be passed to business rules associated
* with the tasks and roles assigned to the user.
* Since version 1.1.11 a param with name 'userId' is added to this array, which holds the value of
* {@link getId()} when {@link CDbAuthManager} or {@link CPhpAuthManager} is used.
* @param boolean $allowCaching whether to allow caching the result of access check.
* When this parameter
* is true (default), if the access check of an operation was performed before,
* its result will be directly returned when calling this method to check the same operation.
* If this parameter is false, this method will always call {@link CAuthManager::checkAccess}
* to obtain the up-to-date access result. Note that this caching is effective
* only within the same request and only works when <code>$params=array()</code>.
* @return boolean whether the operations can be performed by this user.
*/
public function checkAccess($operation, $params = array(), $allowCaching = true)
{
if ($allowCaching && $params === array() && isset($this->_access[$operation])) {
return $this->_access[$operation];
}
$access = Yii::app()->getAuthManager()->checkAccess($operation, $this->getId(), $params);
if ($allowCaching && $params === array()) {
$this->_access[$operation] = $access;
}
return $access;
}
} }

Loading…
Cancel
Save