Fix problem, that Application::getUser can return null

This commit is contained in:
Dmitry Kushnikov
2015-08-12 11:36:13 +03:00
parent ffaf3ef174
commit 19fdd4f96d

View File

@@ -67,7 +67,7 @@ class RateLimiter extends ActionFilter
*/
public function beforeAction($action)
{
$user = $this->user ? : Yii::$app->getUser()->getIdentity(false);
$user = $this->user ? : (Yii::$app->getUser() ? Yii::$app->getUser()->getIdentity(false) : null);
if ($user instanceof RateLimitInterface) {
Yii::trace('Check rate limit', __METHOD__);
$this->checkRateLimit(