public function beforeAction($action)
    {
        if (!parent::beforeAction($action)) {
            return false;
        }
        switch ($action->id) {
        case 'index':
        case 'profile':
        case 'profilePicture':
            if (Yii::$app->user->isGuest) {
                $this->redirect(['login']);

                return false;
            }
            break;
        case 'login':
        case 'recovery':
            if ($action->id === 'recovery' && !$this->module->recoveryEnabled) {
                throw new AccessDeniedHttpException(Yii::t('usr', 'Password recovery has not been enabled.'));
            }
            if (!Yii::$app->user->isGuest) {
                $this->goBack();

                return false;
            }
            break;
        case 'register':
            if (!$this->module->registrationEnabled) {
                throw new AccessDeniedHttpException(Yii::t('usr', 'Registration has not been enabled.'));
            }
            if (!Yii::$app->user->isGuest) {
                $this->redirect(['profile']);

                return false;
            }
            break;
        case 'verify':
            if (!isset($_GET['activationKey'])) {
                throw new BadRequestHttpException(Yii::t('usr', 'Activation key is missing.'));
            }
            break;
        }

        return true;
    }