summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
Diffstat (limited to 'settings')
-rw-r--r--settings/controller/userscontroller.php6
-rw-r--r--settings/middleware/subadminmiddleware.php14
2 files changed, 15 insertions, 5 deletions
diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php
index 3e5455751ab..0abcabed11c 100644
--- a/settings/controller/userscontroller.php
+++ b/settings/controller/userscontroller.php
@@ -176,7 +176,11 @@ class UsersController extends Controller {
$avatarAvailable = false;
if ($this->config->getSystemValue('enable_avatars', true) === true) {
- $avatarAvailable = $this->avatarManager->getAvatar($user->getUID())->exists();
+ try {
+ $avatarAvailable = $this->avatarManager->getAvatar($user->getUID())->exists();
+ } catch (\Exception $e) {
+ //No avatar yet
+ }
}
return [
diff --git a/settings/middleware/subadminmiddleware.php b/settings/middleware/subadminmiddleware.php
index 00f221721a6..8e138bdc1a8 100644
--- a/settings/middleware/subadminmiddleware.php
+++ b/settings/middleware/subadminmiddleware.php
@@ -23,6 +23,7 @@
namespace OC\Settings\Middleware;
use OC\AppFramework\Http;
+use OC\Appframework\Middleware\Security\Exceptions\NotAdminException;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Middleware;
@@ -58,7 +59,7 @@ class SubadminMiddleware extends Middleware {
public function beforeController($controller, $methodName) {
if(!$this->reflector->hasAnnotation('NoSubadminRequired')) {
if(!$this->isSubAdmin) {
- throw new \Exception('Logged in user must be a subadmin');
+ throw new NotAdminException('Logged in user must be a subadmin');
}
}
}
@@ -69,11 +70,16 @@ class SubadminMiddleware extends Middleware {
* @param string $methodName
* @param \Exception $exception
* @return TemplateResponse
+ * @throws \Exception
*/
public function afterException($controller, $methodName, \Exception $exception) {
- $response = new TemplateResponse('core', '403', array(), 'guest');
- $response->setStatus(Http::STATUS_FORBIDDEN);
- return $response;
+ if($exception instanceof NotAdminException) {
+ $response = new TemplateResponse('core', '403', array(), 'guest');
+ $response->setStatus(Http::STATUS_FORBIDDEN);
+ return $response;
+ }
+
+ throw $exception;
}
}