/** * User avatar management * @throws \Ffcms\Core\Exception\NativeException * @throws \Ffcms\Core\Exception\SyntaxException */ public function actionAvatar() { if (!App::$User->isAuth()) { throw new ForbiddenException('You must be authorized user!'); } // get user identity and model object $user = App::$User->identity(); $model = new FormAvatarUpload(true); // validate model post data if ($model->send()) { if ($model->validate()) { $model->copyFile($user); App::$Session->getFlashBag()->add('success', __('Avatar is successful changed')); } else { App::$Session->getFlashBag()->add('error', __('File upload is failed!')); } } return $this->view->render('avatar', ['user' => $user, 'model' => $model]); }