From f05fd650fb58a9cc920d87c7d1e861b00719049f Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Mon, 26 Jan 2015 17:17:38 +0100 Subject: [PATCH] added an event hook to apiauthaction.php to enable header notifications --- edited-gnu-social-files/lib/apiauthaction.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/edited-gnu-social-files/lib/apiauthaction.php b/edited-gnu-social-files/lib/apiauthaction.php index 04b3587..e197053 100644 --- a/edited-gnu-social-files/lib/apiauthaction.php +++ b/edited-gnu-social-files/lib/apiauthaction.php @@ -87,13 +87,16 @@ class ApiAuthAction extends ApiAction // qvitterfix, accepts regular login session - if (common_logged_in()) { - $this->scoped = Profile::current(); - $this->auth_user = $this->scoped->getUser(); - $this->access = self::READ_WRITE; - } - - else { + if (common_logged_in()) { + $this->scoped = Profile::current(); + $this->auth_user = $this->scoped->getUser(); + if (!$this->auth_user->hasRight(Right::API)) { + // TRANS: Authorization exception thrown when a user without API access tries to access the API. + throw new AuthorizationException(_('Not allowed to use API.')); + } + $this->access = self::READ_WRITE; + Event::handle('EndSetApiUser', array($this->auth_user)); + } else { $oauthReq = $this->getOAuthRequest(); if (!$oauthReq) {